Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c#System.Data.SQLite参数错误_C#_Parameters_System.data.sqlite - Fatal编程技术网

c#System.Data.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

我在C#上使用SQlite数据库,参数有一个错误问题

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注入