Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios SQlite3 2534查询后出现错误无法打开数据库文件_Ios_Sqlite_Sqlcipher - Fatal编程技术网

Ios SQlite3 2534查询后出现错误无法打开数据库文件

Ios SQlite3 2534查询后出现错误无法打开数据库文件,ios,sqlite,sqlcipher,Ios,Sqlite,Sqlcipher,例如,我的代码 - (BOOL)openDB:(NSString*)filename { DBPathString =filename; sqlite3_stmt *statement; if (sqlite3_open([DBPathString UTF8String], &database) == SQLITE_OK) { NSString *password = [[NSUserDefaults standardUserDefaults

例如,我的代码

- (BOOL)openDB:(NSString*)filename
{

    DBPathString =filename;
    sqlite3_stmt *statement;

    if (sqlite3_open([DBPathString UTF8String], &database) == SQLITE_OK) {

        NSString *password = [[NSUserDefaults standardUserDefaults] objectForKey:@"Password"];
        const char* key = [password UTF8String];
        sqlite3_key(database, key, strlen(key));



        NSString *querySql = [NSString stringWithFormat:@"SELECT  sum(value) , income_date, count(income_date) FROM incomes WHERE income_date between '1990-01-01' and '2014-01-01' GROUP BY income_date" ];

        const char *query_sql = [querySql UTF8String];

        if (sqlite3_prepare(database, query_sql, -1, &statement, NULL) == SQLITE_OK) {
            while (sqlite3_step(statement) == SQLITE_ROW) {
                float value = sqlite3_column_double(statement, 0);
                NSString* date = [[NSString alloc] initWithUTF8String:(const char *)sqlite3_column_text(statement, 1)];
                int count = sqlite3_column_int(statement, 2);

                NSMutableDictionary *daysThingsDataDetail = [[NSMutableDictionary alloc] init];

                [daysThingsDataDetail setObject:[NSNumber numberWithFloat:value] forKey:@"value"];
                [daysThingsDataDetail setObject:[NSNumber numberWithInt:count] forKey:@"count"];

                [daysThingsData setObject:daysThingsDataDetail forKey:date];

                //NSLog(@"%g", value);
            }

        }
    } else {
        NSLog(@"failed opened DB %s ", sqlite3_errmsg(database));
        sqlite3_close(database);
        return NO;
    }



    sqlite3_close(database);
    return YES;
}
报考

   NSString * Filename = [NSString stringWithFormat:@"test.sqlite3"];
     NSString *DBPathString = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:Filename];
    BOOL result = YES;
    int count = 0;
    while (result) {
        result = [self openDB:DBPathString];
        count++;
        NSLog(@"%d", count);
    }
2013-08-08 15:11:27.023 xxx[16407:c07]2534 2013-08-08 15:11:27.023 xxx[16407:c07]打开数据库失败无法打开数据库文件 2013-08-08 15:11:27.024 xxx[16407:c07]2535


如果您多次运行该程序,它是否总是在同一个位置失败?是的,总是,我使用SQLITECIPHER不同的查询dos不重要。2534之后,您没有从
sqlite\u close()
检查返回代码。你确定会成功吗?