using MySql.Data.MySqlClient; using System; using System.Data; namespace Test.BitCount { class Program { public static string connectingStr = "Data Source=192.168.11.41;Port=3306;Initial Catalog=zxdcrm;user id=root;password=sa123456.;"; static void Main(string[] args) { Random rd = new Random(); Console.WriteLine("麻溜的开始插入测试数据!"); try { using (MySqlConnection conn = new MySqlConnection(connectingStr)) { if (conn.State != ConnectionState.Open) conn.Open(); MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = CommandType.Text; cmd.Connection = conn; for (int i = 0; i < 2000000; i++) { long bitvalue = (long)Math.Floor(rd.NextDouble() * 10000000D); string sql = "insert into lable_realtest(lable)values(" + bitvalue + ")"; //var param = new List() //{ // new MySqlParameter(){ DbType=DbType.Int64,ParameterName="@lable", Value=bitvalue } //}; //MySqlDbHelper.ExecuteNonQuery(connectingStr, CommandType.Text, sql, param.ToArray()); cmd.CommandText = sql; //cmd.Parameters.Add(new MySqlParameter() { DbType = DbType.Int64, ParameterName = "@lable", Value = bitvalue }); cmd.ExecuteNonQuery(); } } } catch (Exception e) { Console.WriteLine("错误:" + e.Message); } Console.WriteLine("插入200W条数据成功!"); Console.ReadLine(); } } }