I am a new comer to Xcode and seeking to learning myself, my problem might be naive however i actually need helps. I am learning creating an e-book by gaining knowledge from a finished project with source code. It really works perfectly about recording bookmark through sqlite3. However when I produce a new project with various title and path, built pharse of libsqlite3.dylib properly and replicated just about everything from the code, the else statement is known as and crashes when I am attempting to visit bookmark window.

Here's some question I requested myself,

  1. did I miss anything, or unsuccessful on altering names or pathways? clarified: no.
  2. because the one runs perfectly and also the other one with almost same code crashes, what is the most possible mistake? clarified: the couple of variations from all of these two project,etc path, title, content in file.

I Quickly transformed the database file title from the good project, also it becomes crashes. I could not believe, because I heard that sqlite3_open([dbPath UTF8String], &dataBase); can create file whether it does not exist, why will not it simply produce a new file using the new title after it had been told to gain access to the brand new file?

Second test Used to do is by hand altering the db file path from the new project towards the db file path from the original one. such as the path isn't any more [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; but it's @"/Customers/~(path from the original one)~/Documents/archive" and omg it really works. However I can not let it rest like this cause that path means nothing on the real apple iphone also it still is dependent the db file from the original one.

A minimum of I understand the road really matters and that i appears really missing some factor like db file during my new project. But the truth is I did not find any db file within the path from the original project, it appears exist and important, but does not show in finder.

I even attempted copying the file to my new path programmaticlly, like calling [self createEditableCopyOfDatabaseIfNeeded] using the new and also the old path. That's all I attempted to date.

The strange factor could it be in some way record font and color after a mystery attempt, but nonetheless crashes ongoing to bookmark window.

That's all I attempted in 72 hours. Assistance you answer the question or at best understand how I had been upset after 1000's attempts. Awaiting help and thanks greatly!

const char *createSQL = "CREATE TABLE Otherwise Is available BOOKMARK(pos REAL PRIMARY KEY,fontsize REAL,bookpath TEXT)"

recently added: Because the program instantly problem the crash once the database isn't prepared, the mistake meg, as someone stated, is useless. All I want is maybe making sqlite3_prepare(dataBase, [querySQL UTF8String], -1, &statement, nil) == SQLITE_OK not false..

Why not print the worthiness written to errorMsg? Which will a minimum of let you know why you are not creating the database.

NSLog(@"%@",[NSString stringWithUTF8String:errorMsg])

The SQL you are using to produce the table within the new DB seems to become screwed up. Try getting rid of the 's

Do this rather:

const char *createSQL = "CREATE TABLE IF NOT EXISTS BOOKMARK(pos REAL PRIMARY KEY, fontsize REAL, bookpath TEXT)";

Furthermore you need to have a look at what sqlite3_prepare really returns. The SQLite documentation gives a listing of error codes to check on against. A good example of logging the mistake code:

int ret = sqlite3_prepare(dataBase, [querySQL UTF8String], -1, &statement, nil);
if (ret != SQLITE_OK) {
    NSLog(@"Error calling sqlite3_prepare: %d", ret);
}