从 sqlite 读取 10 位整数到 C++程序
我正在尝试读取存储在 sqlite 数据库中的 10-12 位有符号整数值。我想将它读入我的 C++ 代码中的 int 变量。我正在尝试以下查询,但我知道我在某个地方出错了,因为我从数据库检索的值始终是负数,与数据库中的值不同。
"SELECT _id FROM Picture where Time<%lld"
然后,我使用 sprintf 将整数值附加到上面的字符串,然后将其发送到 sqlite。当我打印查询时,它显示否定。长整数。我的查询做错了什么?
谢谢,
艾布
I am trying to read a 10-12 digit signed integer value stored in a sqlite database. I want to read it into an int variable in my c++ code. I am trying the following query but I know I am going wrong somewhere as the value I retrieve from the database is always a negative number, different from the one in the database.
"SELECT _id FROM Picture where Time<%lld"
I am then appending the integer value to the above string, before sending it to sqlite, by using sprintf. When I print out the query, it shows a neg. long int number. What am I doing wrong with the query?
Thanks,
Ab
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道我哪里出了问题。我试图读取的字段包含 64 位整数类型,并且我使用 sqlite3_column_int 而不是 sqlite3_column_int64。我将其更改为后者,并将数据返回到我的 c++signed long long 变量中。
感谢您给我一点指导。
I figured out where I was going wrong. The field I was trying to read holds 64-bit integer type and I was using sqlite3_column_int instead of sqlite3_column_int64. I changed it to the latter and got the data back in my c++ signed long long variable.
Thanks for giving me little bit of direction there.