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);

...

Umair_uas
  • 673
  • 1
  • 9
  • 27
  • could you provide some code showing how you are using sqlite? – sergio May 17 '11 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. – SayeedHussain May 17 '11 at 20:03

2 Answers2

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 :)

Community
  • 1
  • 1
WaaleedKhan
  • 685
  • 7
  • 18
0

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

Jason Clark
  • 1,307
  • 6
  • 26
  • 51