sqlite 错误 14 [无法打开数据库文件] iphone xcode
你好,我正在 iPhone 中使用数据库。一段时间后,我的应用程序出现了此错误。
sqlite error 14 [unable to open database file]
我的应用程序运行良好,但有时会生成上述错误。解决方案是什么? 有代码:
[lovkid openDatabase:[appDelegate getDBPath]];
NSString *Flag = [NSString stringWithFormat:@"%@", appDelegate.selectimage];
int recId = (int)appDelegate.Id;
NSLog(@"recID = %d",appDelegate.Id);
updateStmt1 = nil;
if(updateStmt1 == nil)
{
const char *sql ="UPDATE 'char' SET `Pic`=? WHERE `id`=?";
if(sqlite3_prepare_v2(database1, sql, -1, &updateStmt1, NULL) != SQLITE_OK)
NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(database1));
}
sqlite3_bind_text(updateStmt1, 1, [Flag UTF8String], -1, SQLITE_STATIC);
sqlite3_bind_int(updateStmt1, 2, recId);
if(SQLITE_DONE != sqlite3_step(updateStmt1))
NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database1));
else
NSLog(@"no error");
sqlite3_reset(updateStmt1);
sqlite3_finalize(updateStmt1);
...
Hi i am using database in iphone. After along time, My application gave this error
sqlite error 14 [unable to open database file]
My application is going good but some times it generates the above error.What is the solution?
There is the code:
[lovkid openDatabase:[appDelegate getDBPath]];
NSString *Flag = [NSString stringWithFormat:@"%@", appDelegate.selectimage];
int recId = (int)appDelegate.Id;
NSLog(@"recID = %d",appDelegate.Id);
updateStmt1 = nil;
if(updateStmt1 == nil)
{
const char *sql ="UPDATE 'char' SET `Pic`=? WHERE `id`=?";
if(sqlite3_prepare_v2(database1, sql, -1, &updateStmt1, NULL) != SQLITE_OK)
NSAssert1(0, @"Error while creating add statement. '%s'", sqlite3_errmsg(database1));
}
sqlite3_bind_text(updateStmt1, 1, [Flag UTF8String], -1, SQLITE_STATIC);
sqlite3_bind_int(updateStmt1, 2, recId);
if(SQLITE_DONE != sqlite3_step(updateStmt1))
NSAssert1(0, @"Error while inserting data. '%s'", sqlite3_errmsg(database1));
else
NSLog(@"no error");
sqlite3_reset(updateStmt1);
sqlite3_finalize(updateStmt1);
...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,你需要尝试我的答案 帖子
并确保您在应用程序委托中编写了(帖子的)两个函数,这样您的应用程序将打开数据库一次
让我知道它是否有效
干杯:)
well u need to try out my answer from the post
and make sure u write the two functions (of the post ) in ur application delgate that way ur app will open DB once
Let me Know if it worked
Cheers :)
SQLite错误14可以通过更改数据库文件存储目录中的设置来解决。
The SQLite error 14 can be solved by changing the settings in the directory where the database file is stored.