DB property out of scope ?

I’ve got a global database property in a module called OrdersDB

Then I got this code as soon as the app launches…

#if LITE then
dim OrdersDb as new SQLiteDatabase
dim OrdersDb as new CubeSQLServer

The problem is that as soon as the main window is open OrdersDB goes out of scope… How do I get OrderdDB to be either a cubesqlserver or just a sqlitedatabase global property, in my app, depending on Lite = true or not.
I hope I made myself clear.
Thanks for the help.

When you use Dim you are creating a local instance of the object. Change your code to

[code]#if LITE then
OrdersDb = new SQLiteDatabase
OrdersDb = new CubeSQLServer


This will then create the instance using the global property.

Wayne… there has to be a global DIM someplace… and this example is creating one of TWO different datatypes… Yes they are both databases, but they are NOT the same class types…

Yep, If I follow Wayne’s advice I get a "Type Database has no member named “databaseFile” because later in the code I have

#if LITE then

OrdersDB.databaseFile = GetFolderItem("c:\\DataHCP.rsd")

What’s the right way to do what I want ? (one app two alternative databases, either cube for PRO or sqlite fro LITE version). Is it possible ?

If OrdersDB is a database, then you can cast that property to either SQLiteDatabase Or CubeSQLServer (or odbc, mysql etc) in order apply connection data.

To add a database file to OrdersDB you would use something like

OrdersDB = New Database SQLiteDatabase(OrdersDB).DatabaseFile = GetFolderItem("c:\\DataHCP.rsd")

Alright! it’s working now… I don’t understand very much the logic behind it… but it’s working…

Thanks a lot Wayne…

Btw: if you wish to avoid all this typecasting and use of the Isa operator, etc., then you can make use of an interface.

I made a video tutorial here:

Sample xojo project here:

I’ll take a look at it. Thnks