i have two entries in my database
sqlite> select *from courses;
1|ME|273|Statics|MWF|02:20 pm-03:20 pm|James M. Pitarresi|LH 002
2|CS|328|Internet|TR|02:20 pm-03:20 pm|Steflik|eb 23
and i have following code but it does only show first entry in my database
-(NSMutableArray *) getCourses
{
courses = [[NSMutableArray alloc] init];
FMDatabase *db = [FMDatabase databaseWithPath:[Utility getDatabasePath]];
[db open];
FMResultSet *results = [db executeQuery:@"SELECT * FROM courses"];
if ([db hadError]) {
NSLog(@"DB Error %d: %@", [db lastErrorCode], [db lastErrorMessage]);
}
while([results next])
{
[courses addObject:[results stringForColumn:@"Subject"]];
[courses addObject:[results stringForColumn:@"Course_Number"]];
[courses addObject:[results stringForColumn:@"Course_Title"]];
[courses addObject:[results stringForColumn:@"Days"]];
[courses addObject:[results stringForColumn:@"Time"]];
[courses addObject:[results stringForColumn:@"Instructor"]];
[courses addObject:[results stringForColumn:@"Location"]];
}
NSLog(@"loop %@ ",courses);
[results close];
[db close];
return courses;
}
my output is, it doesnt show second entry
loop ( ME, 273, Statics, MWF, "02:20 pm-03:20 pm", "James M. Pitarresi", "LH 002" )
any ideas why this happens?
i dont know why but when i change the database name or create a new database problem solved