Im using FMDB in my iphone app (SDK 6.1). I had 3 DB's working using FMDB in this app. I added another DB file to the same app. This one should also return results, but in fact its just returning 0 results. If I used sqlite3 in the unix prompt and replicate my query (select * from tablename) I see results.
Anyone see anything wrong with this code? I turned on error checking as well and get no errors when I run the code. Ive tried deleting the app and re-installing it both in simulator and on iphone and get same results.
Thanks for any help!
FMDatabase *database = [FMDatabase databaseWithPath:file];
database.logsErrors = YES;
if (![database open])
{
[Log log:TERR :@"ERROR Opening Database <%@>", file];
return FILE_NOT_FOUND;
}
NSString *selquery = [[[NSString alloc] initWithFormat:@"SELECT * FROM %@",
tablename] autorelease];
[Log log:TINFO :@"selquery: %@", selquery];
FMResultSet *results = [database executeQuery:selquery];
NSUInteger count = [database changes]; // how many rows affected apparently
if (!count)
{
[Log log:TINFO :@"NO RESULTS FOUND, count = %d", count];
return NO_SQL_RESULTS;
}
if ([database hadError])
{
NSString *msg = [[[NSString alloc] initWithFormat:@"Database Error <%@> %d: %@", dbname, [database lastErrorCode], [database lastErrorMessage]] autorelease];
[Log log:TERR :msg];
[Log log:TSERVLOG :msg];
return DB_ERROR;
}
SearchItem *item = nil;
while ([results next])
{