我使用MYSQL连接了数据库 在数据库的query中使用查询语句可以查到想要的数据
在程序中就出问题了,
string mysql = string.Format("select * from active");
MySqlCommand cmd = new MySqlCommand(mysql, db.conn);
MySqlDataReader sdr = cmd.ExecuteReader(); if (!sdr.HasRows)
{
timer3.Enabled = false;
timer4.Enabled = false;
this.pictureBox2.Controls.Clear();
MessageBox.Show("The area is not Message!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
...
}
使用断点调试,将mysql语句放入query中查询,得到的数据不为空,但是在if(!sdr.HasRows)这句判断的时候sdr.HasRows值为flase,结果是跳出"The area is not message!",请问将查询语句放到数据库中查询可以查到数据,但是判断是否为空的时候为什么值为空呢,是什么原因
在程序中就出问题了,
string mysql = string.Format("select * from active");
MySqlCommand cmd = new MySqlCommand(mysql, db.conn);
MySqlDataReader sdr = cmd.ExecuteReader(); if (!sdr.HasRows)
{
timer3.Enabled = false;
timer4.Enabled = false;
this.pictureBox2.Controls.Clear();
MessageBox.Show("The area is not Message!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
...
}
使用断点调试,将mysql语句放入query中查询,得到的数据不为空,但是在if(!sdr.HasRows)这句判断的时候sdr.HasRows值为flase,结果是跳出"The area is not message!",请问将查询语句放到数据库中查询可以查到数据,但是判断是否为空的时候为什么值为空呢,是什么原因
if(sdr.Read())
{
...
}