简体   繁体   English

错误:尝试在sql 3中为IPhone编写只读数据库

[英]Error: attempt to write a readonly database in sql 3 for IPhone

I'm trying to update values in SQL3 Database in my Iphone Application. 我正在尝试在我的Iphone应用程序中更新SQL3数据库中的值。 But it keeps showing me this Error: Error: attempt to write a readonly database Any Help?? 但它一直向我显示此错误:错误:尝试编写只读数据库任何帮助?

This is the update code: 这是更新代码:

  - (void)updateAlarms:(AlarmsBean *)todoItem//TodoItem: (AlarmsBean*)todoItem
  {
NSLog(@"UPDATE");
if (updateAlarmsStatement == NULL)
{
    NSLog(@"updateAlarmsStatement == NULL ");
    sqlite3_prepare_v2(database, 
                       "UPDATE T1 SET A2 = ?, A3 = ?, A4 = ? , A5 = ? , A6 = ? , A7 = ?    WHERE A1 = 1",
                       -1, 
                       &updateAlarmsStatement, 
                       NULL);
    NSLog(@"updateAlarmsStatement == NULL ");
}
if (updateAlarmsStatement == NULL)
{
    NSLog(@"AHMAD updateAlarmsStatement == NULL ");


}
NSLog(@"after if  ");
sqlite3_reset(updateAlarmsStatement);
sqlite3_bind_text(updateAlarmsStatement, 1, [todoItem.AA2 UTF8String], -1, SQLITE_TRANSIENT);
sqlite3_bind_int(updateAlarmsStatement, 2, todoItem.AA3);
sqlite3_bind_text(updateAlarmsStatement, 3, [todoItem.AA4 UTF8String], -1, SQLITE_TRANSIENT);

sqlite3_bind_int(updateAlarmsStatement, 4, todoItem.AA5);

sqlite3_bind_text(updateAlarmsStatement, 5, [todoItem.AA6 UTF8String], -1, SQLITE_TRANSIENT);

sqlite3_bind_int(updateAlarmsStatement, 6, todoItem.AA7);
sqlite3_bind_int(updateAlarmsStatement, 7, todoItem.AA1);
sqlite3_step(updateAlarmsStatement);


if(sqlite3_step(updateAlarmsStatement) != SQLITE_DONE ) {
    NSLog( @"Save Error: %s", sqlite3_errmsg(database) );
}
else {
    sqlite3_reset(updateAlarmsStatement);
    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"UIAlertView" message:@"Record update" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    [alert release];
    alert = nil;

}

} }

you need to copy your database file to document directory and use it from there before making any write attempts. 您需要将数据库文件复制到文档目录并在进行任何写入尝试之前从那里使用它。 you cannot write to any object in your application resources. 您无法写入应用程序资源中的任何对象。

please check if you are doing so.. 请检查你是否这样做..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM