Hi, I have a trouble in my database - somehow at some point it appears that a database is being closed even before it was opened.
If a database was not opened I am using the following statement: if (!database) then break;
when *database is being set to nil (database = nil) when it was not opened.
Am I doing it in a right way? Or there is some other error in my code?
Here is my code:
-(BOOL) loadDB: (NSString*) dbPath {
//Database was opened before
if (database) {
sqlite3_close(database);
database = nil;
}
//Opening database
if (sqlite3_open([dbPath UTF8String], &database) != SQLITE_OK)
{
database = nil;
return FALSE;
}
return TRUE;
}
The code is being called for multiple times and at some time it throws an exception. Why may this happen?
When I am using debugger to see where a problem occured, it shows me: sqlite3_close(database);
Thank you in advance.