【发布时间】:2015-08-11 20:53:49
【问题描述】:
我正在尝试使用sqlite3 DB 构建 iOS 应用程序,我只是在带有 ios 8.3 的 iPhone 6 和带有 ios 8.1 的 iPhone 5s 和带有 ios 7.1 的 iPhone 4 上测试它的工作完美,但是当尝试在另一部 iPhone 上测试它时6 与 ios 8.3 应用程序运行和数据库工作,但当尝试执行以下查询时它不显示任何内容!
//this class copy DB if needed and return the Db path.
DBLOADER *test =[[DBLOADER alloc]init];
BOOL openDatabaseResult = sqlite3_open([test.getDBPath UTF8String], &db);
if(openDatabaseResult == SQLITE_OK) {
NSString *sql =[NSString stringWithFormat:@"select name,st from department_name where ky='%@' ",_key];
sqlite3_stmt *statement;
if(sqlite3_prepare(db, [sql UTF8String], -1, &statement, nil)== SQLITE_OK)
{
NSLog(@"sql run");
while (sqlite3_step(statement)==SQLITE_ROW) {
char *field1 =(char *)sqlite3_column_text(statement, 0);
NSString *field1str =[NSString stringWithUTF8String:field1];
[DBnamez addObject:field1str];
NSLog(@"Name----->%@",field1str);
char *field2 =(char *)sqlite3_column_text(statement, 1);
NSString *field2str =[NSString stringWithUTF8String:field2];
[DBstatus addObject:field2str];
NSLog(@"->%@",field2str);
NSLog(@"status----->%@",field2str);
}
NSLog(@"read Data successfully!!");
[self.table reloadData];
}
else{
NSLog(@"cant read data!!!");
}
}
但只是 nslog 打印:cannot read data!!!
【问题讨论】:
-
重置模拟器或删除应用重试
-
你有没有打电话给sqlite3_errmsg()的原因?
标签: ios objective-c iphone sqlite