我試圖插入一些值到我的sqlite數據庫。數據庫已經在手機上的doc文件夾中。我不知道發生了什麼問題。我設置跟蹤執行,但數據庫告訴我,它沒有任何錯誤。有人能幫我嗎?iOS:SQLite插入查詢不起作用
if([[TRSharedLocalDatabase openDatabase] executeUpdateWithFormat:@"INSERT INTO event (title,date,address,latitude,longitude,location,facebookID,picPath,description) VALUES (%@,%@,%@,%@,%@,%@,%@,%@,%@)",event.title ,event.date, event.address, [NSNumber numberWithDouble:event.geoPoint.longitude], [NSNumber numberWithDouble:event.geoPoint.latitude], event.location.objectId, event.facebookID ,picPath ,event.description]) {
NSLog(@"Ok");
} else {
NSLog(@"Not Ok");
}
+(FMDatabase *)openDatabase {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"4PartyLocalSystem.sqlite"];
**FMDatabase *database = [FMDatabase databaseWithPath:writableDBPath];**
[database open];
[database setTraceExecution:YES];
return database;
}
2013年8月6日13:21:42.499 4Party [13018:907]的executeUpdate:INSERT INTO事件(標題,日期,地址,緯度,經度,位置,facebookID,picPath介紹)VALUES
拉斐爾,如果你提供的有關'TRSharedLocalDatabase'更多信息,這將是有益的。你可以分享「openDatabase」方法的代碼嗎?確切地說,如果不瞭解更多關於代碼的功能,將很難幫助您。 – Aaron
openDatabase方法僅用於打開數據庫。這裏是:NSArray * paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); NSString * documentsDirectory = [paths objectAtIndex:0]; NSString * writableDBPath = [documentsDirectory stringByAppendingPathComponent:@「4PartyLocalSystem.sqlite」]; FMDatabase * database = [FMDatabase databaseWithPath:writableDBPath]; [數據庫打開]; [數據庫setTraceExecution:YES]; 返回數據庫; –
請通過編輯將問題添加到問題中,而不是將其添加到評論中。在評論 –