Hi,
I saved constant values into a table of a SQLite3 database. I've done this via Terminal. Then I filled the table with some values. The database is set up all right: Queries in Terminal and in DB inspectors like 'SELECT * FROM myTable' return all values and they are all right.
I added the database file into my XCode project.
Now I've got two problems:
The first one: When I click on 'Build & Go' the database file isn't copied correctly into the iPhone simulator directory. sqlite3_prepare_v2() returns ERROR 1 and opening the database file manually gets me an error too.
If I copy the original database file from the project directory into the simulator's application directory then sqlite3_prepare_v2() works.
Unlike Apple's SQLBook example, my code doesn't make a copy of the DB explicitly as I don't need an editable copy of it. I just want to read values out of it.
Is this a bug or a...
My second problem: When I drop off queries like 'SELECT name FROM Constants' in Terminal, I get all the values and all are correct (like mentioned above).
But when I do this in my code:
Code:
CONNECTION EXISTS...
const char *sql = "SELECT name FROM Constants";
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(database, sql, -1, &statement, NULL) == SQLITE_OK) {
// We "step" through the results - once for each row.
while (sqlite3_step(statement) == SQLITE_ROW) {
// The second parameter indicates the column index into the result set.
char *name = (char*)sqlite3_column_text(statement, 0);
}
}
The first result is ALWAYS:
Code:
[\x8bU\x10\x8d\x83`
The following names are all correct but the first one is a mess. I've already created a brand new database file with a new table and other values. Same errornous value.
Has someone experienced a similar problem one day and found the solution to this?