I've create a DB file from firefox tool SQlite manager names myTestDB
the db has a table names ViewController1,and the table content 5 columns(there value are all TEXT)
I want read the value by columns name,so here's my code....
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *myDbPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"myTestDB.sqlite"];
FMDatabase *myDB = [FMDatabase databaseWithPath:myDbPath];
if (![myDB open]) {
NSLog(@"Could not open db.");
return ;
}
else
{
NSLog(@"DB open!");
}
FMResultSet *rs = [myDB executeQuery:@"SELECT * FROM ViewController1"];
for (int i =0; i<[rs columnCount]; i++) {
NSLog(@"%@",[rs stringForColumnIndex:i]);
}
}
there's many sample codes use the method
while([rs next])
{
//Loading somethin...
}
but if i use it,the code won't get into the while loop even once
and my code just log 5 (null) to me....
Why is that...?