Umair_uas
Umair_uas

Reputation: 673

sqlite error 14 [unable to open database file] iphone xcode

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

...

Upvotes: 1

Views: 4011

Answers (2)

Jason Clark
Jason Clark

Reputation: 1425

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

Upvotes: 0

WaaleedKhan
WaaleedKhan

Reputation: 685

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

Upvotes: 1

Related Questions