C#这样连接mysql有重复连接?
[code=c#] private void OnTimer(object sender, EventArgs e)
{
MySqlCommand command = new MySqlCommand("select xy,sendtime from phonenumber", msg.Program.mycon );
MySqlDataReader reader = command.ExecuteReader(); ;
try
{
while (reader.Read())
{
if (reader.HasRows)
{
。。。。。。
//////////////////////////////////////////////////////////////////////////////
if (时 == Convert.ToInt32(strShi) && 分 == Convert.ToInt32(strFen))
{
try
{
//这里总报错说已经有一个连接了
command = new MySqlCommand("update phonenumber set sendtime='' ", msg.Program.mycon);
command.ExecuteNonQuery();
}
catch (Exception ee)
{
Console.WriteLine(ee.Message);
}
}
}
}
}
catch (Exception)
{
Console.WriteLine("查询失败了!");
}
reader.Close();
}
[/code]
msg.Program.mycon
msg是namespace,pragram是类,mycom是public static变量,变量在main中初始化