Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 10-01-2008, 02:12 PM   #1 (permalink)
Norbert
New Member
 
Join Date: Jul 2008
Posts: 37
Norbert is on a distinguished road
Default SQLite Problems: Simulator copy + first value of every query is mumbo-jumbo

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?
Norbert is offline   Reply With Quote
 

» Advertisements
» Online Users: 436
19 members and 417 guests
Absentia, apatsufas, brainspoon, comicool, Davor, Domele, habitatus, iMax 3060, jbro, john love, JohnnyFlash, linkmx, matador1978, mistergreen2011, m_rozzi, NSString, revg, RickSDK
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,551
Threads: 94,078
Posts: 402,725
Top Poster: BrianSlick (7,990)
Welcome to our newest member, hongto24
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:17 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.