这是我的代码:
private void loadlist()
{
comboBox1.Items.Clear();
cn.Open();
cmd.CommandText = "Select * from info";
dr = cmd.ExecuteNonQuery();
if (dr.HasRows)
{
while (dr.Read())
{
comboBox1.Items.Add(dr[0].ToString());
}
cn.Close();
}
}
错误发生在这一行:
dr = cmd.ExecuteNonQuery();
我在用System.Data.SqlClient;
和:
SqlConnection cn = new SqlConnection(@"//HERE IS MY STRING CONNECTION");
SqlCommand cmd = new SqlCommand();
SqlDataReader dr;