I managed to get into this situation when connecting to a sqlite DB… (please look at the pic)
https://drive.google.com/open?id=0B3LQKr6mspNPWGxhY2N6U2JCQXM
Error = False
ErrorCode = 1
Is this an ‘as expected’ behavior ?
I managed to get into this situation when connecting to a sqlite DB… (please look at the pic)
https://drive.google.com/open?id=0B3LQKr6mspNPWGxhY2N6U2JCQXM
Error = False
ErrorCode = 1
Is this an ‘as expected’ behavior ?
Have you connected to the database with db.Connect?
That’s the error I get right after .createdatabasefile returns true… So I guess I should be connected
try to connect the db even after the createdatabasefile method.
Maybe it is the system you’re on but, in your photo, the DatabaseFile item looks odd to me. Are you sure that’s a valid file?
Please post your code here.
[code]
Dim asyncbckp as boolean = True
app.BackingUpNow = True
Dim backupFile As Folderitem
backupFile = GetFolderItem(app.UbicacionBackup+“HotelDB.bak”)
If backupFile Is Nil Then
app.BackingUpNow = False
Return
end
app.BackupDB = New SQLiteDatabase
app.BackupDB.DatabaseFile = backupFile
dim ok as Boolean = app.BackupDB.Connect
If app.BackupDB.CreateDatabaseFile Then
if app.BackupDB.Error then
app.DisplayBCKDatabaseError
end
app.BackupHandler1 = New BackupHandler
// TYPE OF BCK
if asyncbckp = false then
SQLiteDatabase(app.HotelDB).BackUp(app.BackupDB, nil, -1) // SYNC
app.BackingUpNow = False
else
SQLiteDatabase(app.HotelDB).BackUp(app.BackupDB, app.BackupHandler1, 10) // ASYNC
end
else
app.BackingUpNow = False
app.DisplayBCKDatabaseError
End If
end[/code]
@Dale Arends Yep, Dale… it is a valid file…
First off, if on the first run-through, if the .bak file doesn’t already exist, the connect will generate an error that the file doesn’t exist. Subsequent runs should be ok.
I think a better approach is to check and see if the file exists and then do a connect if it does or a createdatabasefile if it doesn’t. The Create step will also connect if the create succeeds.
Remove this line of code:
dim ok as Boolean = app.BackupDB.Connect
Read http://documentation.xojo.com/index.php/SQLiteDatabase.CreateDatabaseFile and you’ll find that if the database already exists the method acts like the Connect method.
Even better. Remove:
dim ok as Boolean = app.BackupDB.Connect
And then Replace:
If app.BackupDB.CreateDatabaseFile Then
With:
If app.BackupDB.Connect Then