Im trying to insert some values to my sqlite database. The db is already of the doc folder on the phone. I cant figure out what is going wrong. I set trace executing but the db tells me that it does not have any error. Can someone help me?
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-08-06 13:21:42.499 4Party[13018:907] executeUpdate: INSERT INTO event (title,date,address,latitude,longitude,location,facebookID,picPath,description) VALUES (?,?,?,?,?,@,?,?,?)
TRSharedLocalDatabase. Can you share the code for the methodopenDatabase? It will be difficult to help you without knowing more about what that code is doing, exactly.databaseWithPath:. You will also want to consider adding some error handling to your code on the SQLite operations. That will give you more information about specific errors.