如何解决Sqlite查询不起作用
| 我正在尝试获取特定行类型的所有行详细信息。Select * from MainTable where JOB1=@Paint
它不起作用。我尝试了更多选择,但没有成功。谁能告诉我Objective-C的正确格式是什么?
完整的代码就像
if(sqlite3_open([databasePath UTF8String],&database) == sqlITE_OK) {
//const char *sqlStatement = \"SELECT * FROM MainTable\"; ??it is working
const char *sqlStatement = \"SELECT * FROM MainTable where JOB1=\'Paint\'\";//but not this one
sqlite3_stmt *compiledStatement;
NSLog(@\"query set\");
if(sqlite3_prepare_v2(database,sqlStatement,-1,&compiledStatement,NULL) == sqlITE_OK) {
while(sqlite3_step(compiledStatement) == sqlITE_ROW) {
Nsstring *job = [Nsstring stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement,0)];
Nsstring *image = [Nsstring stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement,1)];
Nsstring *tools = [Nsstring stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement,2)];
Nsstring *materials = [Nsstring stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement,3)];
Nsstring *people = [Nsstring stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement,4)];
Nsstring *safety = [Nsstring stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement,5)];
NSLog(@\"%@\",job);
NSLog(@\"image %@\",image);
NSLog(@\"tools %@\",tools);
NSLog(@\"materials %@\",materials);
NSLog(@\"people %@\",people);
NSLog(@\"safety %@\",safety);
解决方法
您可以使用firefox插件SQLite管理器触发SQLite数据库查询
https://addons.mozilla.org/zh-CN/firefox/addon/sqlite-manager/
您可以在程序中编写相同的查询。如果仍然没有运行,请发布您的代码段。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。