On this page we will show how easy it really is to switch an existed Xojo project, that uses built-in SQLite database to Valentina SQLite Server.
We will use example “Xojo/Example Projects/Database/SQLite/SQLiteExample.xojo_binary_project” to modify it. Let`s copy it, for example, to the Desktop and open in Xojo.
To start working with Valentina plugin we should add one or few of its initialization methods:
In this example, we are going to access Valentina Server as SQLite Server. So let's add in Application class a new event handler Open().
Also we should shutdown Valentina plugin using one of 3 shutdown methods. Let's add into Application class a new event handler Close().
We will make this application to be able to work in both modes Local and Client!
To choose a mode let's add checkbox ClientMode on the top of window with default value = False
Please notice, that in real life app, you will use, most probably, some boolean flag instead visual checkbox.
Double click button “Create SQLite DB” to see its method, which creates local SQLite db in the original example of Xojo.
In the above method we can see that original code uses
App.DB = new SQLiteDatabase
Instead we should use VSQLiteDatabase class from V4RB plugin. For this click property DB in the App class
and change its type in the inspector to VSQLiteDatabase:
At this point you can try to RUN this modified project in LOCAL mode, to see that it still works using built-in SQLite engine of Xojo.
Let's open the folder of Valentina Server to see later that database will be created in the folder 'databases_sqlite'.
Now let's start application again. But at first click checkbox 'ClientMode' and then click all 4 buttons. You will see that application still works, and you see the correct results:
Again let's look into Valentina Server folder. This time you will see new folder 'databases_sqlite' with database 'example.sqlite'.
We was need only
to convert EXISTING SQLite Example of Xojo to Valentina SQLite Server.
The same amount of job you will need for projects of any size, because you only need correct db create/open/connect code.