Bu hatalarla ilgili pek çok yazı aramak zorunda kaldım, ancak yine de sorunu çözemiyorum. İşte benim kodum, neyin yanlış gittiğini görmek için bana yardım edebilir mi? Ben veritabanı sorunları (Bu durumda, Oracle) varken benim DBA söylüyorBöyle bir Tablo hatası yok
- (void) copyDatabaseIfNeeded {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"SQL.sqlite"];
if (sqlite3_open([path UTF8String], &newDBconnection) == SQLITE_OK)
{
NSLog(@"Database opened successfully");
if(updateStmt == nil) {
NSString *updStmt = [NSString stringWithFormat: @"UPDATE Coffee SET CoffeeName = '500 Plus', Price = '1.40' Where CoffeeID= '3'"];
const char *mupdate_stmt = [updStmt UTF8String];
if(sqlite3_prepare_v2(newDBconnection, mupdate_stmt, -1, &updateStmt, NULL) != SQLITE_OK){
NSAssert1(0, @"Error while creating update statement. '%s'", sqlite3_errmsg(newDBconnection));
} else {
NSLog(@"Update successful");
}
}
if(SQLITE_DONE != sqlite3_step(updateStmt))
NSAssert1(0, @"Error while updating. '%s'", sqlite3_errmsg(newDBconnection));
else {
sqlite3_reset(updateStmt);
NSLog(@"Step successful");
}
}
else
{
NSLog(@"Error in opening database ");
}
}
Ben "sqlite_master SELECT * FROM" SQL yürüterek Kahve tablosunu bulabilirsiniz ve veritabanı güncellenmesi konusunda sadece zaman, başarıyla açıldı Eğer SQLite tarayıcı veya komutu vardır: ile kontrol ediyoruz, hata – Sunny
@Sunny meydana satır aracı, farklı dosya açıyor olabilirsiniz. 'UPDATE' yapmadan önce 'code '' log'unu log 've' sqlite_master 'ile aynı kod ile sorgulayın. – hamstergene
tamam .. o şimdi çalışıyor :) Ayrıca veritabanı içindeki her tablonun adını göstermek için SQLite komut satırı aracı '.tables' seçeneğini kullanabilirsiniz size – Sunny