我有一个数据网格视图。在此 DGV 中,第一列是组合框列。I want to make, when this combobox value is selected next fild will be filled automatically from database. 但是那里显示一个错误。
没有为 OleDbDataReader dr1 = cmd1.ExecuteReader() 上的一个或多个必需参数提供值;
我发布代码。请帮我。
OleDbConnection con = new OleDbConnection(conn);
con.Open();
for (int i = 0; i < dgv.Rows.Count; i++)
{
string query = "select Description from General where AccCode='" +
dgv.Rows[i].Cells[0].Value +
"' and conpanyID='" +
label1.Text + "'";
OleDbCommand cmd1 = new OleDbCommand(query, con);
//OleDbDataAdapter daBranchName = new OleDbDataAdapter(cmd);
OleDbDataReader dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
dgv.Rows[i].Cells[1].Value = dr1["Description"].ToString();
}
}
con.Close();