标签:
.net长时间连接mysql导致超时;
方式一:连接用完后,就关闭连接
方式二:增加C#的执行sqlcommand时间
增加了这一句,问题解决了
using (MySqlConnection conn = new MySqlConnection(mysqlCon.ConnectionString)) { mysqlDa.SelectCommand.Connection = conn; //0表上永久,默认是30 mysqlDa.SelectCommand.CommandTimeout = 0; conn.Open(); MySqlTransaction tran = conn.BeginTransaction(); mysqlDa.SelectCommand.Transaction = tran; mysqlDa.Fill(ds, "sp_AllInsert"); tran.Commit(); string returnStr = return_str.Value.ToString(); tbCompanyID.Text = returnStr; MessageBox.Show(returnStr); }
标签:
原文地址:http://www.cnblogs.com/2star/p/5403157.html