即使结果有值,控件也不会进入 while 循环 [results next]
Control does not go inside while loop [results next] even if results has values
我正在 iOS 中使用 FMDB 执行搜索查询操作。如果我打印结果的值,它会显示一些值,但控制不会进入,而 loop.Here 是我的代码。
tempStr
是搜索框的值:
FMResultSet *results=[db executeQuery:@"select * From Notes where Note_Title LIKE '@%'",tempStr];
marrDataDB=[[NSMutableArray alloc] init];
NSLog(@"Results for query : %@ ",results);
while ([results next])
{
NSLog(@"I am in WHile LOOP");
searchHelper=[[dbHelper alloc]init];
helper.nTitle=[results stringForColumn:@"Note_Title"];
searchHelper.nDesc=[results stringForColumn:@"Note_Desc"];
searchHelper.nATime= [results stringForColumn:@"Note_A_Time"];
[marrDataDB addObject:searchHelper];
}
提前致谢
如果这是真实代码,则查询有错字,应该是:
@"select * From Notes where Note_Title LIKE '%@'"
所以我猜你得到了一个有效的 FMResultSet
对象,你记录了它,但它不包含任何实际结果,因为查询没有匹配任何东西。
看看你是否从数据库中得到任何结果
NSUInteger count = [db intForQuery:@"select count(Note_Title) From Notes where Note_Title LIKE '@%'",tempStr];
NSLog(@"count :%d",count);
我正在 iOS 中使用 FMDB 执行搜索查询操作。如果我打印结果的值,它会显示一些值,但控制不会进入,而 loop.Here 是我的代码。
tempStr
是搜索框的值:
FMResultSet *results=[db executeQuery:@"select * From Notes where Note_Title LIKE '@%'",tempStr];
marrDataDB=[[NSMutableArray alloc] init];
NSLog(@"Results for query : %@ ",results);
while ([results next])
{
NSLog(@"I am in WHile LOOP");
searchHelper=[[dbHelper alloc]init];
helper.nTitle=[results stringForColumn:@"Note_Title"];
searchHelper.nDesc=[results stringForColumn:@"Note_Desc"];
searchHelper.nATime= [results stringForColumn:@"Note_A_Time"];
[marrDataDB addObject:searchHelper];
}
提前致谢
如果这是真实代码,则查询有错字,应该是:
@"select * From Notes where Note_Title LIKE '%@'"
所以我猜你得到了一个有效的 FMResultSet
对象,你记录了它,但它不包含任何实际结果,因为查询没有匹配任何东西。
看看你是否从数据库中得到任何结果
NSUInteger count = [db intForQuery:@"select count(Note_Title) From Notes where Note_Title LIKE '@%'",tempStr];
NSLog(@"count :%d",count);