使用 C# 在 SQLite 中添加参数 [英] Adding parameters in SQLite with C#

查看:53
本文介绍了使用 C# 在 SQLite 中添加参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在学习 SQLite,我无法将参数正确编译到命令中.当我执行以下代码时:

Im just learning SQLite and I can't get my parameters to compile into the command properly. When I execute the following code:

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();

我收到 SQLite 异常.检查 CommandText 后,我​​发现无论我做什么都没有正确添加参数:INSERT INTO [StringData] VALUE (?,?)

I get a SQLite Exception. Upon inspecting the CommandText I discover that whatever I'm doing is not correctly adding the parameters: INSERT INTO [StringData] VALUE (?,?)

对我缺少什么有任何想法吗?

Any ideas what I'm missing?

谢谢

推荐答案

尝试 VALUES 而不是 VALUE.

这篇关于使用 C# 在 SQLite 中添加参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆