I really get frustrated with the error .I have spent two days in for getting solve that .But it not get fix ,When getting data from database at that time there no problem .But when fire the insert statement.I get this errors:
Assertion failure in -[NewJourney addJourney], /Users/HarishYadav/Desktop/JourneyMapper/Journey/NewJourney.m:114
2011-07-05 17:23:13.739 Journey[24328:207] * Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Error while inserting data. ‘database is locked”
* Call stack at first throw:
Here is my code for inserting the value in database
-(void)addJourney
{
if (addStmt == nil)
{
const char * sql = "insert into UserJourney(JourneyName,LocationName,Description) Values (?,?,?)";
if (sqlite3_prepare_v2(database, sql, -1,&addStmt ,NULL) != SQLITE_OK)
NSAssert1(0,@"Error while creating add statement. '%s'",sqlite3_errmsg(database));
}
sqlite3_bind_text(addStmt, 1, [journeyname UTF8String], -1,SQLITE_TRANSIENT);
sqlite3_bind_text(addStmt, 2, [journeylocation UTF8String],-1, SQLITE_TRANSIENT);
sqlite3_bind_text(addStmt, 3, [journeydescription UTF8String],-1 , SQLITE_TRANSIENT);
if (SQLITE_DONE != sqlite3_step(addStmt))
NSAssert1(0,@"Error while inserting data. '%s'",sqlite3_errmsg(database));
else
journeyID = sqlite3_last_insert_rowid(database);
sqlite3_reset(addStmt);
}
What was the problem in this
Thanks in advance
You need to use after you complete your statement
in every function where you use database interaction.