请帮忙解决update语句错误?
我的是access数据库,检查了很多次,还是提示错误?请高手帮忙解决?
提示:---------------------------
---------------------------
UPDATE 语句的语法错误。
---------------------------
确定
---------------------------
代码如下:
OleDbCommand UpdateCommand = new OleDbCommand();
UpdateCommand.Connection = connection;
string updatesql = "update from zhangdan set CustomerID=@CustomerID,DeviceName=@DeviceName,count=@count,UnitPrice=@UnitPrice,AllUnitPrice=@AllUnitPrice,DataTime=@DataTime where ID=@ID";
UpdateCommand.CommandText = updatesql;
UpdateCommand.Parameters.Add("@CustomerID", OleDbType.Integer, 4, "CustomerID");
UpdateCommand.Parameters.Add("@DeviceName", OleDbType.VarChar, 20, "DeviceName");
UpdateCommand.Parameters.Add("@count", OleDbType.Integer, 4, "count");
UpdateCommand.Parameters.Add("@UnitPrice", OleDbType.VarChar, 20, "UnitPrice");
UpdateCommand.Parameters.Add("@AllUnitPrice", OleDbType.VarChar, 20, "AllUnitPrice");
UpdateCommand.Parameters.Add("@DataTime", OleDbType.DBTimeStamp, 20, "DataTime");
UpdateCommand.Parameters.Add("@ID", OleDbType.Integer, 4, "ID");
adapter.UpdateCommand = UpdateCommand;
------解决方案--------------------
OleDbCommand UpdateCommand = new OleDbCommand();
UpdateCommand.Connection = connection;
string updatesql = "update from zhangdan set CustomerID=?,DeviceName=?,count=?,UnitPrice=?,AllUnitPrice=?,DataTime=? where ID=?";
UpdateCommand.CommandText = updatesql;
UpdateCommand.Parameters.Add("?", OleDbType.Integer, 4, "CustomerID");
UpdateCommand.Parameters.Add("?", OleDbType.VarChar, 20, "DeviceName");
UpdateCommand.Parameters.Add("?", OleDbType.Integer, 4, "count");
UpdateCommand.Parameters.Add("?", OleDbType.VarChar, 20, "UnitPrice");
UpdateCommand.Parameters.Add("?", OleDbType.VarChar, 20, "AllUnitPrice");
UpdateCommand.Parameters.Add("?", OleDbType.DBTimeStamp, 20, "DataTime");
UpdateCommand.Parameters.Add("?", OleDbType.Integer, 4, "ID");
adapter.UpdateCommand = UpdateCommand;
------解决方案--------------------
都没有给各个变量赋值。