0

**UPDATE** I have discovered that the database is not opening in the ios device.(only for update?? but it does for a select statement)

It will open in the similator.

I am using FMDB wrapper for SQlite. Everything works fine in the simulator. On the iOS device the database doesn't update.

I download the database like this and save it to this location:

- (void)connectionDidFinishLoading:(NSURLConnection *)connection
{    
   NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0]; // Get documents directory
NSString *writableDBPath = [documentsDirectory stringByAppendingPathComponent:@"ARCdb.sqlite"];

[responseData writeToFile:writableDBPath atomically:YES];

NSLog(@"DB written");

[connection cancel];

}

I can read from the database without issue using FMDB but when I try to update it using this code:

//OPEN DB

-(void)openDB
{
NSArray *docPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [docPaths objectAtIndex:0];
NSString *dbPath = [documentsDir stringByAppendingPathComponent:@"ARCdb.sqlite"];

database = [FMDatabase databaseWithPath:dbPath];
[database open];

}

//UPDATE DB

[self openDB];

     [database executeUpdate:@"UPDATE inventory SET CompanyID = ?, UserID = ?, Scanned = ?,    SignedByName = ?, SignedByFileName = ? where BottleID = ?", customerIDPass, UserIDPass, @"1", signedby, filePath, [bottleIDPassFinal objectAtIndex:a], nil];

}

[database close];

Like I said works in simulator but not on ios device. I am not saving in app bundle so I don't understand.

PLEASE HELP.

Example code would help if needed thank you.

CrazyGoose
  • 51
  • 1
  • 10
  • I checked [database lastError], [database lastErrorCode], [database lastErrorMessage] and do not get any error messages. – CrazyGoose Feb 06 '14 at 23:50
  • 1
    On a device filenames are case sensitive. Are you sure that is the exact name of the database file? – rmaddy Feb 07 '14 at 00:02
  • Yep, keep in mind that SQLite will happily open a nonexistent database. – Hot Licks Feb 07 '14 at 00:05
  • But you don't actually describe an error. What happens when you try to write? How do you know it's not working? (And transfer the app data off of the device to your Mac and see if the DB looks correct from the sqlite3 command line.) – Hot Licks Feb 07 '14 at 00:08
  • On the iOS device the database doesn't update. – CrazyGoose Feb 07 '14 at 03:19

0 Answers0