To obtain a good approximation for data fitting with a spline, parameters and knots have to be treated as variables frequently. There are two kinds of considerations. The first is to choose parameters with which the fitting are better while the knots of the B-spline bases are in a fix. The choices of parameters include uniform parameterization, cumulative chord length parameterization, centripetal model parameterization and Gauss-Newton approach. The other is to determine parameters in advance (generally cumulative chord length parameterization) and then to compute the knots of B-spline bases by some algorithms such that the fitting becomes more precise. In this paper both the parameters and the knots of the B-spline bases are considered simultaneously by using genetic algorithms such that the fitting B-spline curve to data attains its optimum in the total least squares sense. With this, the parameters and the knots can be appropriately determined simultaneously. The method given in this paper have advantages of robustness (the resulting curve is initial-value-free), better precision and fewer vertexes compared with Gauss-Newton approach and Piegl's algorithm. Two examples of data fitting are given to show that the genetic algorithms-based fitting curves are better in approximation. Fitting Bézier curve to a set of data by using genetic algorithms is also studied.