[英]Unable to retrieve data from SQLite database iOS6.0
When i run build ios5.0 or less then Sqlite response correct and retrieve data its work fine but when run on ios6.0 i am trying to fetch data from my.sqlite database but it is not executing my if case. 当我运行构建ios5.0或更少时,Sqlite响应更正并检索数据工作正常,但在ios6.0上运行时,我试图从my.sqlite数据库中获取数据,但它没有执行我的if情况。 It always enters in else condition.
它总是进入其他条件。 What wrong thing i am doing?
我做错了什么? I am not able to execute my if case ie
if(sqlite3_prepare_v2(database, sqlQuerry, -1, &querryStatement, NULL)==SQLITE_OK).
我无法执行我的if if
if(sqlite3_prepare_v2(database, sqlQuerry, -1, &querryStatement, NULL)==SQLITE_OK).
for reference check this code . 供参考检查此代码。
NSLog(@"sqlite3_prepare_v2 = %d SQLITE_OK %d ",sqlite3_prepare_v2(sqlite, [strQuery UTF8String], -1, &compiledStatement, nil),SQLITE_OK);
if(sqlite3_prepare_v2(sqlite, [strQuery UTF8String], -1, &compiledStatement, nil)==SQLITE_OK)
{
NSLog(@"sqlite3_step = %d SQLITE_ROW %d ",sqlite3_step(compiledStatement),SQLITE_ROW);
while (sqlite3_step(compiledStatement)==SQLITE_ROW)
{ if(sqlite3_column_text(compiledStatement, 2) != nil)
modelObj.Name = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
}
}
else
{
}
On iOS6.0 log Print 在iOS6.0上日志打印
sqlite3_prepare_v2 = 1 SQLITE_OK 0
sqlite3_step = 21 SQLITE_ROW 100
On iOS5.0 log Print 在iOS5.0上打印日志
sqlite3_prepare_v2 = 0 SQLITE_OK 0
sqlite3_step = 100 SQLITE_ROW 100
Place in the else this, so we can see the error that is resulting.. 放在else中,所以我们可以看到导致的错误..
if(sqlite3_prepare_v2(sqlite, [strQuery UTF8String], -1, &compiledStatement, nil)==SQLITE_OK)
{
NSLog(@"sqlite3_step = %d SQLITE_ROW %d ",sqlite3_step(compiledStatement),SQLITE_ROW);
while (sqlite3_step(compiledStatement)==SQLITE_ROW)
{ if(sqlite3_column_text(compiledStatement, 2) != nil)
modelObj.Name = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)];
}
}
else{
//error
NSLog(@"Failed to open database. Error: %s",sqlite3_errmsg(database));
}
尝试从您的设备(或模拟器)中删除您的应用程序,然后清理和构建
I'm not 100% sure but regarding this: NULL is a void * , nil is an id 我不是100%肯定,但对此: NULL是一个void * , nil是一个id
So if you can change this: 所以如果你能改变这个:
if(sqlite3_prepare_v2(sqlite, [strQuery UTF8String], -1, &compiledStatement, nil)==SQLITE_OK)
Whit this: 惠特这个:
if(sqlite3_prepare_v2(sqlite, [strQuery UTF8String], -1, &compiledStatement, NULL)==SQLITE_OK)
I just change nil with NULL. 我只用NULL改变nil。 Again not 100% sure but only this I see in your code.
再次不是100%肯定,但只有我在你的代码中看到。 I always use NULL :)
我总是使用NULL :)
Hope this help... 希望这有帮助......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.