1

Hi i am using database in iphone. After along time, My application gave this error

sqlite error 14 [unable to open database file] 

My application is going good but some times it generates the above error.What is the solution? There is the code:

[lovkid openDatabase:[appDelegate getDBPath]];
NSString *Flag = [NSString stringWithFormat:@"%@", appDelegate.selectimage];
    int recId = (int)appDelegate.Id;
    NSLog(@"recID = %d",appDelegate.Id);

    updateStmt1 = nil;
    if(updateStmt1 == nil) 
    {

        const char *sql ="UPDATE 'char' SET `Pic`=? WHERE `id`=?";
        if(sqlite3_prepare_v2(database1, sql, -1, &updateStmt1, NULL) != SQLITE_OK)
            NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(database1));
    }
    sqlite3_bind_text(updateStmt1, 1, [Flag UTF8String], -1, SQLITE_STATIC);
    sqlite3_bind_int(updateStmt1, 2, recId);

    if(SQLITE_DONE != sqlite3_step(updateStmt1))
        NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database1));
    else
        NSLog(@"no error");



    sqlite3_reset(updateStmt1);
    sqlite3_finalize(updateStmt1);

...

2
  • could you provide some code showing how you are using sqlite? Commented May 17, 2011 at 15:44
  • the function you have written here looks correct. Show the function definitions of 1.openDatabase and 2. getDBPath. I am inclined to think there are missing pieces in your code. Provide these two functions and we should be able to figure this one out quick. Commented May 17, 2011 at 20:03

2 Answers 2

1

well u need to try out my answer from the post

and make sure u write the two functions (of the post ) in ur application delgate that way ur app will open DB once

Let me Know if it worked

Cheers :)

Sign up to request clarification or add additional context in comments.

Comments

-1

The SQLite error 14 can be solved by changing the settings in the directory where the database file is stored.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.