sqlite 没有更新我的数据库 iOS [英] sqlite is not updating my database iOS
本文介绍了sqlite 没有更新我的数据库 iOS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试更新我的 sqlite 数据库,但此代码对我不起作用.请帮我找出问题所在.
I am trying to update my sqlite database but this code is not working for me. Please help me to find what is wrong with this.
-(BOOL)StoreFavourite:(NSString*)fav :(int)DuaId
{
NSString* mydbpath=[self pathfinder];
const char *dbpath=[mydbpath UTF8String];
if(sqlite3_open(dbpath,&database )==SQLITE_OK)
{
NSString *query = [NSString stringWithFormat:@"UPDATE Dua SET
favourite=\'%@\' WHERE dua_id=%d ",fav,DuaId];
const char *query_statement=[query UTF8String];
if(sqlite3_prepare_v2(database, query_statement, -1, &statement, NULL)==SQLITE_OK)
{
while(sqlite3_step(statement) == SQLITE_DONE)
{
return YES;
}
sqlite3_finalize(statement);
}
}
return YES;
}
推荐答案
请通过输入 NSLog
检查您的mydbpath".我认为您提供的路径不正确.
也尝试使用:
Please check your "mydbpath" by putting NSLog
.I think you have given incorrect path.
Also try to use:
NSString *query = [NSString stringWithFormat:@"UPDATE Dua SET favourite='%@' WHERE dua_id=%d ",fav,DuaId];
这篇关于sqlite 没有更新我的数据库 iOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文