SQLite Select 语句不返回任何内容 - C#
相当简单的问题,我在数据库中有一个表,其中包含一列和十四行。
当尝试返回数据库中的所有行时,我尝试以下操作:
command = new SQLiteCommand("SELECT Value FROM Currency", connection);
然而,当我查看受影响的结果量(以及数组中缺少元素)时,我注意到以下内容:
显然那里什么也没有,我什至用两个单独的工具进行了检查以确认数据在那里。我执行此操作是否错误?我只是想迭代返回的值并将它们存储在数组中。
感谢您抽出时间! 编辑:
解决方案!
int i = 0;
while (dReader.Read())
{
_data[i] = Convert.ToSingle(dReader[0]);
i++;
}
这很好用:)
Fairly simple problem, I have a table in a database that contains one column and fourteen rows.
When trying to return all of the rows in the database I try the following:
command = new SQLiteCommand("SELECT Value FROM Currency", connection);
Yet when I look at the amount of results affected (And the lack of elements in my array) I notice the following:
Apparently there's nothing in there, I've even checked with two seperate tools that confirm the data is in there. Am I executing this incorrectly? I simply want to iterate over the values returned and store them in an array.
Thanks for your time!
Edit:
Solution!
int i = 0;
while (dReader.Read())
{
_data[i] = Convert.ToSingle(dReader[0]);
i++;
}
This works fine :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SqlDataReader.RecordsAffected
< /a> 对于选择查询不受影响。编辑:
SqlDataReader.RecordsAffected
is not affected for select queries.EDIT:
您不应该对
结果集进行循环吗?
Shouldn't you be doing a
to loop through your resultset?