For fitting of ordered plane data by B-spline curve with the least squares, the genetic algorithm is generally used, accompanying the optimization on both the data parameter values and the knots to result in good robust, but easy to fall into local optimum, and without improved fitting precision by increasing the control points of the curve. So what we have done are: combining the particle swarm optimization algorithm into the B-spline curve fitting, taking full advantage of the distribution characteristic for the data, associating the data parameters with the knots, coding simultaneously the ordered data parameter and the number of the control points of the B-spline curve, proposing a new fitness function, dynamically adjusting the number of the control points for the B-spline curve. Experiments show the proposed particle swarm optimization method is able to adaptively reach the optimum curve much faster with much better accuracy accompanied less control points and less evolution times than the genetic algorithm.