c#System.Data.SQLite参数错误
我在C#上使用SQlite数据库,参数有一个错误问题c#System.Data.SQLite参数错误,c#,parameters,system.data.sqlite,C#,Parameters,System.data.sqlite,我在C#上使用SQlite数据库,参数有一个错误问题 using System.Data.SQLite; 以下是主要代码部分: this.dbUpdateCommand = new SQLiteCommand(); dbUpdateCommand.Parameters.AddWithValue("@paramNewValue", (string)this.valueNew); dbUpdateCommand.Parame
using System.Data.SQLite;
以下是主要代码部分:
this.dbUpdateCommand = new SQLiteCommand();
dbUpdateCommand.Parameters.AddWithValue("@paramNewValue", (string)this.valueNew);
dbUpdateCommand.Parameters.AddWithValue("@paramPredValue", (string)this.valuePred);
dbUpdateCommand.Parameters.AddWithValue("@paramTableName", (string) this.tableName);
dbUpdateCommand.Parameters.AddWithValue("@paramColumnName", (string)this.columnInDB);
dbUpdateCommand.Parameters.AddWithValue("@paramKeyField", (string)this.keyFieldInDB);
dbUpdateCommand.Parameters.AddWithValue("@paramKeyValue", (string)this.keyValueInDB);
dbUpdateCommand.CommandText = "UPDATE @paramTableName SET @paramColumnName=@paramNewValue WHERE @paramKeyField=@paramKeyValue;";
dbUpdateCommand.ExecuteNonQuery();
它在“@paramTableName:语法错误”附近抛出异常“SQLite错误”
我尝试创建没有参数但带有字符串连接的纯SQL语句,它使用相同的变量(this.tableName是有效的db tableName)
所以我的参数似乎有问题。有人知道吗?您不能使用参数引用对象(表和列)。您需要将实际的表名和列名放入查询中。执行此操作时请小心SQL注入