I was at this hour and MUST get this job! It supports the release of iPhone applications ... My first time using SQLite. I followed all the tips, and yet my sqlite3_prepare_v2 call gets SQLITE_ERROR (1) every time!
Here is my code from my controller:
NSString *query = @"SELECT * FROM QandA ORDER BY random() LIMIT 1"; // const char *sqlStatement = "SELECT * FROM QandA ORDER BY random() LIMIT 1"; sqlite3_stmt *compiledStatement; // sqlite3_stmt *statement; int prepareStatus = sqlite3_prepare_v2(database, [query UTF8String], -1, &compiledStatement, NULL); if (prepareStatus == SQLITE_OK) {...
You will notice that I tried using "char *" to no avail (among other attempts). My database opens with:
databaseName = @"Facts.sqlite";
In my controller interface:
NSString *databaseName; NSString *databasePath;
I checked in the debugger, and everything looks fine, but the preparation statement fails. I donβt know how to write down the expression that he is trying to compile ... I assume / hope that this is exactly what my SELECT says.
Can anyone help? I'm desperate. Mark
source share