0
我試圖在我的Iphone應用程序中更新SQL3數據庫中的值。 但它不斷顯示我這個錯誤: 錯誤:試圖寫一個只讀數據庫 任何幫助?錯誤:嘗試在sql 3中爲iPhone編寫只讀數據庫
這是更新代碼:
- (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;
}
}