Probably a beginner question, but I do not find the solution. I inserted a database into my project, which worked great. I added some tables and fields, so far, so good. But now: How do I connect to this database? I tried dbDatabase.Connect, but this does not work.
You need to declare the database before connecting to it. I tend to put this in the App.Open event and keep the actual database global so I can keep the connection open until the app exits. (This is from memory so there may be an error or two.)
// Create Database Object, theDB, globally
theDB = New SQLiteDatabase
// Give it a file if necessary
theDB.databaseFile = SpecialFolder.Documents.child("myappdatabase.sqlite")
// Connect to the database
If theDB.databaseFile.exists = True Then
// The database file already exists, so we want to connect to it,
// otherwise you'll have to create the folderitem yourself
If theDB.Connect = False Then
MagBox("Unable to connect to database") // there was an error connecting to the database
Quit
End If
Good luck.
Thanks, Dale, that helped!