0
我想用sqlite3
DB創建iOS應用程序,我只是用ios 8.3和iPhone 5s在ios 8.1和iPhone 4上用ios 7.1測試它,它的工作完美,但是當試圖用ios測試另一個iphone 6時8.3應用程序運行和數據庫工作,但當嘗試執行以下查詢它不顯示任何東西!sqlite3選擇查詢只是不工作在一個設備?
//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()](http://www.sqlite.org/c3ref/errcode.html)? –
非常感謝你的工作 –