From Xojo Documentation

Revision as of 15:06, 8 August 2017 by PLefebvre (talk | contribs)

SQLiteDatabase.AttachDatabase(file As FolderItem, databaseName As String[, password As String]) As Boolean

Supported for all project types and targets.

Attaches the SQLite database referred to by file to the database. It gives the newly attached database the name databaseName.


When a database has been attached, it is possible to do cross-database queries. In order to attach an encrypted database, you must pass the correct password for the database to be attached.

You should prefix all SQL queries to tables in the attached database with the databaseName.


This example attaches a database file to an existing, connected database, currentDB:

Dim attachDBFile As New FolderItem("AttachDB.sqlite")

If currentDB.AttachDatabase(attachDBFile, "locations") Then // currentDB is already connected elsewhere
MsgBox("Database attached.")
// Queries against the attached database would be prefixed with "locations", such as
// SELECT City FROM locations.Addresses WHERE ST = 'TX'
End If