Interface
SQLiteBackupInterface
Description
Used to get progress and status of SQLiteDatabase backups.
Methods
Name |
Parameters |
Returns |
Shared |
---|---|---|---|
errorCode As Integer |
|||
Method descriptions
SQLiteBackupInterface.Complete
Complete
This method is called for you when the SQLiteDatabase.Backup finishes.
You can display a simple message in this method to indicate the back up complete:
MessageBox("Backup is complete.")
SQLiteBackupInterface.Error
Error(errorCode As Integer) As Boolean
This method is called for you when there was an error in the SQLiteDatabase.Backup. The error is return in errorCode.
These are the possible error codes:
Error code |
Description |
---|---|
0 |
No error |
1 |
Source database disconnected |
2 |
Destination database disconnected |
If an error occurs, display it:
MessageBox("Backup error: " + errorCode.ToString)
SQLiteBackupInterface.Progress
Progress(percent As Double, ByRef cancel As Boolean)
This method is called for you as the SQLiteDatabase.Backup progresses, supplying the percent complete in percent. To cancel the backup, set cancel to True.
If your implementing class has a reference to a ProgressBar, you can update it using the percent value:
If BackupProgressBar <> Nil Then
BackupProgressBar.MaximumValue = 100
BackupProgressBar.Value = percent * 100
End If
Notes
This interface is used when you want to track the progress of an asynchronous backup of a SQLiteDatabase using SQLiteDatabase.Backup.
You create a class that implements this interface and then add code to the methods. The methods are called as the backup progresses.
The class must remain in scope while the backup is running.
Sample code
Backing up the database asynchronously requires the use of a separate class that implements SQLiteBackupInterface.
Var backupFile As Folderitem
backupFile = FolderItem.ShowSaveFileDialog("", "backup.sqlite")
If backupFile Is Nil Then Return
' This is a property on the Window so that it stays in scope when the method exits
mBackupDB = New SQLiteDatabase
mBackupDB.DatabaseFile = backupFile
If mBackupDB.CreateDatabase Then
' This is a property on the Window so that it stays in scope when the method exits
mBackupHandler = New BackupHandler
' The window has a progress bar that is updated as the backup progresses
mBackupHandler.BackupProgressBar = BackupProgress
mDB.BackUp(mBackupDB, mBackupHandler)
End If
A class called BackupHandler implements SQLiteBackupInterface and has code in these methods:
Complete:
MessageBox("Backup Complete.")
Error:
MessageBox("There was an error during the backup: " + errorCode.ToString)
Progress:
If BackupProgressBar <> Nil Then
BackupProgressBar.MaximumValue = 100
BackupProgressBar.Visible = True
BackupProgressBar.Value = percent * 100
End If
Compatibility
All project types on all supported operating systems.