sqlite3选择查询只是在一台设备上工作?

时间:2015-05-29 05:45:04

标签: ios objective-c iphone sqlite

我正在尝试使用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!!!

1 个答案:

答案 0 :(得分:0)

重置模拟器或删除应用,然后重试jaleel-nazir