I am facing the problem in the fetching the data from the sqlite database.
I try like this but my data is not getting fetched:
+(void) getInitialDataToDisplay:(NSString *)dbPath
{
JourneyAppDelegate *appDelegate = (JourneyAppDelegate*)[[UIApplication sharedApplication]delegate];
if (sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK)
{
const char *sql = "select JourneyID,JourneyName,LocationName,Description from UserJourney";
sqlite3_stmt *selectStmt;
if(sqlite3_prepare_v2(database, sql, -1, &selectStmt, NULL) == SQLITE_OK)
{
while (sqlite3_step(selectStmt) == SQLITE_ROW)
{
//NSInteger primaryKey = sqlite3_column_int(selectStmt, 0);
NewJourney *journeyobj = [[NewJourney alloc]init];
/**/when my pointer come at this line it goes out of the scope My journeyobj.journeyname ,journeyobj.journeylocation and journeyobj.journeydescription is not getting the value.**
journeyobj.journeyname = [NSString stringWithUTF8String:(char*)sqlite3_column_text(selectStmt, 3)];
journeyobj.journeylocation = [NSString stringWithUTF8String:(char*)sqlite3_column_text(selectStmt, 4)];
journeyobj.journeydescription = [NSString stringWithUTF8String:(char*)sqlite3_column_text(selectStmt, 5)];
journeyobj.isDirty = NO;
[appDelegate.journeyList addObject:journeyobj];
[journeyobj release];
}
}
}
else
{
sqlite3_close(database);
}
}
What is the problem??
Thanks in advance
Also, make sure you only ever have one connection to sqlite open at any time in any thread. Multiple connections won’t work.