Difference between revisions of "SQLiteDatabase.CreateDatabase"

From Xojo Documentation

(Notes)
(Notes)
 
Line 19: Line 19:
 
Try
 
Try
 
   db.CreateDatabase
 
   db.CreateDatabase
Catch error as IOException
+
Catch error As IOException
 
   MessageBox("The database file could not be created: " + error.Message)
 
   MessageBox("The database file could not be created: " + error.Message)
 
End Try
 
End Try

Latest revision as of 18:52, 12 November 2019

Method

SQLiteDatabase.CreateDatabase()

Supported for all project types and targets.

Creates a new SQLiteDatabase using the FolderItem in the DatabaseFile property.

Notes

If the database already exists, this function works like Database.Connect. If CreateDatabase succeeds, the DatabaseFile property will bet set to the DatabaseFile. If CreateDatabase does not succeed, an IOException is raised.

This code creates a database file and catches the exception if the operation fails:

Var db As New SQLiteDatabase
db.DatabaseFile = SpecialFolder.Desktop.Child("MyDatabase.sqlite")
Try
db.CreateDatabase
Catch error As IOException
MessageBox("The database file could not be created: " + error.Message)
End Try