我正在尝试使用sqlite3
数据库构建iOS应用程序,我只是在带有ios 8.3的iphone 8.3和带有ios 8.1和带有ios 7.1的iPhone 4的iPhone 5上测试它的工作完美但是当我尝试测试它时另外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!!!