Bri*_*ney 21 c# sqlite system.data.sqlite
我只是学习SQLite,我无法正确编译命令.当我执行以下代码时:
this.command.CommandText = "INSERT INTO [StringData] VALUE (?,?)";
this.data = new SQLiteParameter();
this.byteIndex = new SQLiteParameter();
this.command.Parameters.Add(this.data);
this.command.Parameters.Add(this.byteIndex);
this.data.Value = data.Data;
this.byteIndex.Value = data.ByteIndex;
this.command.ExecuteNonQuery();
Run Code Online (Sandbox Code Playgroud)
我得到一个SQLite异常.在检查CommandText时,我发现无论我做什么都没有正确添加参数:INSERT INTO [StringData] VALUE (?,?)
我缺少什么想法?
谢谢
Bjö*_*örn 76
尝试不同的方法,在查询中命名字段并在查询中命名参数:
this.command.CommandText = "INSERT INTO StringData (field1, field2) VALUES(@param1, @param2)";
this.command.CommandType = CommandType.Text;
this.command.Parameters.Add(new SQLiteParameter("@param1", data.Data));
this.command.Parameters.Add(new SQLiteParameter("@param2", data.ByteIndex));
...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
68225 次 |
| 最近记录: |