Example doesn't work as shown

The code below is from SQLiteDatabase.Backup - Xojo Documentation

Dim backupDBFile As FolderItem = GetSaveFolderItem("", “backup.sqlite”)

If backupDBFile <> Nil Then
Dim backupDB As New SQLiteDatabase
backupDB.DatabaseFile = backupDBFile
If backupDB.CreateDatabase Then
db.Backup(backupDB, Nil, -1)
MsgBox(“Backup finished!”)
End If
End If

The line above the Message Box creates an error regarding db, “db this item does not exist.”
I’ve tried defining db but nothing seems to work. Under Globals db is Nil and Return s False.

My question is what needs to be changed or added to get the above code to work in a program?

I appreciate the help.

The error message means that the variable db does not exist. In the example project this line is not

db.Backup(backupDB, Nil, -1)


mDB.Backup(backupDB, Nil, -1)

where mDB is a property of the MainWindow class.

In the sample code, “db” is a reference to the original SQLite database that you want to backup. I’ve added a comment to make that more obvious.

You can refer to a complete project that demonstrates SQLite Backup here:

Thank you. I’ll go over the example again.

Shouldn’t the code line:

If backupDB.CreateDatabase Then


If backupDB.CreateDatabaseFile Then

that’s what the code autofill tries to put in, at least in 2014r2.1. I filed a case on this while back, 39373.