有一个奇怪的场景,ADO.Net继续返回“SQLite错误。提供给命令的参数不足”
更新查询:
UPDATE [Device] SET
[DeviceSerial] = @DeviceSerial,
[RegistrationDate] = @RegistrationDate,
[RegistrationNumber] = @RegistrationNumber,
[Password] = @Password,
[Make] = @Make,
[Year] = @Year,
[OdometerStart] = @OdometerStart,
[PurchaseValue] = @PurchaseValue,
[Closed] = @Closed
WHERE [DeviceId] = @DeviceId
参数:
{ "@DeviceSerial", this.DeviceSerial },
{ "@RegistrationDate", this.RegistrationDate },
{ "@RegistrationNumber", this.RegistrationNumber },
{ "@Password", this.Password },
{ "@Make", this.Make },
{ "@Year", this.Year },
{ "@OdometerStart", this.OdometerStart },
{ "@PurchaseValue", this.PurchaseValue },
{ "@Closed", this.Closed },
{ "@DeviceId}", this.DeviceId }
我的DataHandler方法:
public static bool CallSqlText(string sqlStatement, Dictionary<string, object> parameters)
{
ConnectionCheck();
try
{
var cmd = conn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = sqlStatement;
foreach (var item in parameters)
{
cmd.Parameters.AddWithValue(item.Key, item.Value);
}
return (cmd.ExecuteNonQuery() > 0);
}
catch { }
return false;
}
答案 0 :(得分:1)
你有一个错字:“@DeviceId}”应该是“@DeviceId”