在这里,我正在实现一个select查询来从表中获取数据,但是没有任何行被我的查询返回。下面选择查询没有准备好
是我的代码,我现在用:
if ((sqlite3_open([[self dataFilePath] UTF8String], &database))==SQLITE_OK)
{
NSLog(@"DataBase OpeneD..!!");
imageId=[[NSMutableArray alloc] init];
const char *slectImageIdQuery="SELECT * from ts_Gallary;";
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(database, slectImageIdQuery, -1, &statement, nil)==SQLITE_OK)
{
NSLog(@"Query CREATED..!!");
while (sqlite3_step(statement)==SQLITE_ROW)
{
int iId=sqlite3_column_int(statement, 0);
NSString *imgTtl=[NSString stringWithFormat:@"%d",iId];
NSLog(@"image id in while=%d",iId);
[imageId addObject:[NSString stringWithFormat:@"%@",imgTtl]];
}
}
else
{
NSLog(@"query could not be prepared");
}
sqlite3_finalize(statement);
}
sqlite3_close(database);
我的控制台显示:
2011-04-06 17:44:33.381托斯卡纳[4680:207]打开数据库..! ! 2011-04-06 17:44:33.382托斯卡纳[4680:207]查询无法进行制备
注意:这里dataFilePath是方法,其返回我的数据库和数据库的路径是sqlite3的对象
否我的应用程序抛出错误或异常。
有什么问题,我该如何检测问题以及解决问题?
谢谢。