c# OleDb SQL更新语法错误
本文关键字:语法 错误 更新 SQL OleDb | 更新日期: 2023-09-27 17:52:48
我不知道为什么这给了我一个语法错误时,试图更新这个?
string editComp = "UPDATE Competitive SET (PartNumber, Location, Description) values (@Edpart, @Edlocation, @Eddescrip) where SerialNumber = @serial";
command.CommandText = editComp;
command.Parameters.Add("@serial", OleDbType.VarChar).Value = Serialtext.Text;
command.Parameters.Add("@Edpart", OleDbType.VarChar).Value = Parttext.Text;
command.Parameters.Add("@Edlocation", OleDbType.VarChar).Value = cboLocation.Text;
command.Parameters.Add("@Eddescrip", OleDbType.VarChar).Value = Descriptiontext.Text;
command.ExecuteNonQuery();
MessageBox.Show("Successfully Updated");
您正在尝试使用插入语法执行更新查询。为UPDATE使用正确的语法,如:
string editComp = "UPDATE Competitive SET PartNumber=@Edpart, Location=@Edlocation, Description=@Eddescrip";
如果上面的代码不工作,然后尝试替换@Edlocation
, @Eddescrip
和@Edpart
与?