嗨,我将用于填充组合框的表中有空值。我不知道该怎么做。当我运行以下代码时,我收到错误:
数据为空。不能对空值调用此方法或属性。
我需要帮助,我是 mysql 新手
编码 :
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string constring = "datasource=localhost;port=3306;username=root;password=root";
string Query = "SELECT * from database.check WHERE patientname IS NOT NULL";
MySqlConnection conDataBase = new MySqlConnection(constring);
MySqlCommand cmdDataBase = new MySqlCommand(Query, conDataBase);
MySqlDataReader myReader;
try
{
conDataBase.Open();
myReader = cmdDataBase.ExecuteReader();
while (myReader.Read())
{
string namethestore = myReader.GetString("namethestore");
string checkername = myReader.GetString("checkername");
this.textBox65.Text = namethestore;
this.textBox66.Text = checkername;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}