我在运行代码时遇到问题,然后更新成功,但我只想更新一行。当通过我的代码时,所有数据都是更新的。
我的代码是:
代码
protected void imgbtn_Save_Click(object sender, EventArgs e)
{
OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = "update Companies set CompanyFName='" + txt_ComName.Text + "',CompanySName='" + txt_ShortName.Text + "',CompanyeMail='" + txt_email.Text + "',CompanyWebsite='" + txt_website.Text + "'where CompanyId=CompanyId";
cmd.Connection = conn;
OleDbDataAdapter da = new OleDbDataAdapter();
da.UpdateCommand = cmd;
cmd.ExecuteNonQuery();
conn.Close();
BindGridData();
lblError.Font.Bold = true;
lblError.Font.Size = 11;
lblError.Text = "You have successfully modified the case!";
}
我不知道为什么?
请建议我。
“谢谢”