本文介绍了使用Mysqldataadapter.update()插入值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
string InsertQuery = "";
MySqlTransaction transaction;
MySqlConnection con1 = new MySqlConnection();
MySqlDataAdapter ODA;
string server = loggerConnectionString.servername;
con1.ConnectionString ="server="localhost";uid=root;pwd=;database=globasys;";
con1.Open();
transaction = con1.BeginTransaction();
ODA = new MySqlDataAdapter();
InsertQuery = "Insert into tr_config_unit_params " + Environment.NewLine;
InsertQuery += "(unit_param_id,unit_id, unit_param_desc, unit_param_opc_progid, unit_param_host, unit_param_link, unit_param_data_type, unit_param_type) " + Environment.NewLine;
InsertQuery += " VALUES(@unit_param_id,@unit_id,@unit_param_desc, @unit_param_opc_progid, @unit_param_host, @unit_param_link, @unit_param_data_type, @unit_param_type)";;
ODA.InsertCommand =new MySqlCommand(InsertQuery, con1);
ODA.InsertCommand.Parameters.Add("@unit_param_id", MySqlDbType.Int32);
ODA.InsertCommand.Parameters.Add("@unit_id"", MySqlDbType.Int32);
ODA.InsertCommand.Parameters.Add("@unit_param_desc", MySqlDbType.VarChar);
ODA.InsertCommand.Parameters.Add("@unit_param_opc_progid", MySqlDbType.VarChar);
ODA.InsertCommand.Parameters.Add("@unit_param_host", MySqlDbType.VarChar);
ODA.InsertCommand.Parameters.Add("@unit_param_link", MySqlDbType.VarChar);
ODA.InsertCommand.Parameters.Add("@unit_param_data_type", MySqlDbType.Int32);
ODA.InsertCommand.Parameters.Add("@unit_param_type", MySqlDbType.Int32);
ODA.InsertCommand.Transaction = transaction;
DataSet ds = new DataSet();
ds = dt;
int y= ODA.Update(ds,"param");
transaction.Commit();
con1.Close();
</pre>
i have insert the 150000 rows using Mysqldataadapter.update() but the query execute successfully but there is no row insert into the database table in MYSQL
thanks in advance.....
推荐答案
这篇关于使用Mysqldataadapter.update()插入值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!