当我尝试执行以下查询时,MySql.Data.dll中出现“ System.NullReferenceException”类型的未处理异常的错误
private void Ingredients_Load(object sender, EventArgs e)
{
MySqlCommand cmd = new MySqlCommand();
string query = "select count(*) from Inventory";
cmd.CommandText = query;
cmd.Connection = conn;
flag = Convert.ToInt32(cmd.ExecuteScalar());
conn.Close();
for (int i = 1; i <= flag; i++)
{
comboBox1.Items.Add(i);
}
}