DB sequence

If I create a DB, create the tables, how do I just open the DB the next time (w/o creating the tables again …) What is the IF condition for that ?

If you are using SQLLite then you’d check for the database file existing.

[code] Dim f As FolderItem
Dim db As New SQLiteDatabase

f = SpecialFolder.ApplicationData.Child(“mydatabase.rsd”)

db.DatabaseFile = f
If f.Exists Then
If Not db.Connect Then
MsgBox “Can’t connect to database file”
End If
If db.CreateDatabaseFile Then
’ Create tables here
MsgBox “Can’t create database file”
End If
End If

’ Database is either created or openned

Another way to do this is to create a table. In the database which includes the version number of the database itself. This adds the flexibility of being able to upgrade the database by just checking this number. If its lower than you expect, upgrade the db and set the new version number.

Edgar, others,

using code from the documentation, I created a simple project (smalle) that allows you to see (read, understand) how things are working with SQLIteDatabase.


The project displays two images logos (SQLite and Xojo) in its single window. It also have three TextAreas and one ListBox to read the records you wrote.

Commands are in the SQLite Menu.

There are two images (screen shots) included in the zip: one with only the running window, the second have the SQLite Menu open.

It does:
Create the sqlite file and add the Table,
Open the sqlite database (in fact all sqlite database, but read only the one created by this project *),
Add one Record (that is three fields: First last Name, Job and Year),
Displays the saved sqlite data base file contents.

I do not do that on purpose and I just saw it, the keyboard shortcuts for these menus are: NORD (North in English). very funny !

The code inside the project is working. You may find typos, want additions, and so on. Drop me a mail and I will see what I can do.

  • This can be changed.

Thank you Emile.