我有一个数据网格视图。我从数据库中提取数据并显示在这个 gridview 中。但是当我尝试通过单击按钮来更新它时,它会显示错误。
try
{
string update = "update Tank_Head set Item_Code='?', Opening_Bal='?', Tank_Description='?', where Tank_Unit='?' and companyID='?'";
OleDbCommand cmd = new OleDbCommand(update, con);
cmd.Parameters.AddWithValue("@Item_Code", cbItemEdit.Text);
cmd.Parameters.AddWithValue("@Opening_Bal", txtOpeningBalanceEdit.Text);
cmd.Parameters.AddWithValue("@Tank_Description", txtTankDesEdit.Text);
cmd.Parameters.AddWithValue("@Tank_Unit", txtTankUnitEdit.Text);
cmd.Parameters.AddWithValue("@companyID", label1.Text);
i = cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
finally
{
con.Close();
if (i != 0)
{
pnlView.Visible = true;
pnlEdit.Visible = false;
}
}