SQLite SELECT in 语句不检索任何行
在开发 Backberry 应用程序时,我在处理 sqlite 数据库时遇到以下问题。
该语句在 sqlite 管理器中工作正常,并检索数据库中的相应数据:
SELECT Z_PK,Z_NAME,Z_STATUS from ZTABLE WHERE Z_PK=1
现在,如果我创建一个像这样的 net.rim.device.api.database.Statement 实例:
Statement statement = this.db.createStatement("SELECT Z_PK,Z_NAME,Z_STATUS FROM ZTABLE WHERE Z_PK=?1");
statement.prepare();
statement.bind(1, id.intValue());
Cursor cursor = statement.getCursor();
Row row = cursor.getRow();
变量 row 为 null,而 this.db 已很好地初始化(它适用于 INSERT 语句);此外 id 也很好地初始化为值 1。
我看不出与 sqlite 示例项目相比有什么不同以及为什么它不能正常工作。
有人可以帮我吗? 多谢。
Working on an application for Backberry, I have the following issue dealing with sqlite database.
This statement works fine in sqlite manager and retrieves the corresponding data in the database :
SELECT Z_PK,Z_NAME,Z_STATUS from ZTABLE WHERE Z_PK=1
Now if I create an instance of net.rim.device.api.database.Statement like this :
Statement statement = this.db.createStatement("SELECT Z_PK,Z_NAME,Z_STATUS FROM ZTABLE WHERE Z_PK=?1");
statement.prepare();
statement.bind(1, id.intValue());
Cursor cursor = statement.getCursor();
Row row = cursor.getRow();
the variable row is null whereas this.db is well initialized (it works for an INSERT statement) ; moreover id is also well initialized with value 1.
I cannot see what is different compared to the sqlite sample project and why this does not work as it should.
Can anybody help me please ?
Thanks a lot.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我刚刚错过了调用 next() 的小但非常重要的一行:
Ok, I just missed the small but very important line with the call to next() :