views:

255

answers:

1

I am using an sqlite3 database file in my iPhone App project to read from during runtime. First, for development purposes, I created the file on my desktop with Navicat for SQLite.

Reading this file using this code works:

NSString *strTest = [NSString stringWithString:@"select tbl_name from sqlite_master"]; 
const char *sql_test = [strTest UTF8String];
sqlite3_stmt *statement_test;
returnval = sqlite3_prepare_v2(database, sql_test, -1, &statement_test, NULL);
NSString *strerr = [NSString stringWithCString:sqlite3_errmsg(database)];
NSLog(@"\n\nTabellen in DB [%@] (Error:%d Description:%@)\n",path,returnval,strerr);
while (sqlite3_step(statement_test) == SQLITE_ROW) {
 NSString *table = [NSString stringWithUTF8String:(char   *)sqlite3_column_text(statement_test, 0)];
 NSLog(@"%@\n",table);
}
sqlite3_finalize(statement_test);

Using a file, created by a partner company using PHP, it doesn't work. The guy said, that he just created it using PhP. Unfortunately thats all I know at his point but I will try to get to know more about it for you guys to be able to point me into the right direction.

With the file from the company I am getting the error code 26 "file is encrypted or is not a database"

What can be the reason for this behaviour. Is the file encrypted? The partner company told me that they did not use any compression by their knowledge. Or could something happen to the file in other ways? Might it be created with a wrong version of sqlite?? They are using PHP5 as fas as I know.

Maybe someone can help me here :) I know its not that much information and I will try to deliver more.

A: 

The problem actually was that the partner team created a sqlite 2.x file instead of a version 3 file. That caused the function sqlite3_prepare_v2 to return the error code 26.

Nonlinearsound