Using a database as an App property

This code works

Dim dbPath as string
Dim f as folderitem

dbPath=“C:\Files\WarrantyAutomation\WarrantyAutomation”
f = New FolderItem(dbPath)
dim db as new SQLiteDatabase
app.db.DatabaseFile=f

If the database is a property of the App then I get a Nil databse error using the code below.

Dim dbPath as string
Dim f as folderitem

dbPath=“C:\Files\WarrantyAutomation\WarrantyAutomation”
f = New FolderItem(dbPath)
app.db.DatabaseFile=f

Note in the former you did

   dim db as new SQLiteDatabase

but not in the latter

try

dbPath="C:\\Files\\WarrantyAutomation\\WarrantyAutomation"
f = New FolderItem(dbPath)
app.db = new SQLiteDatabase // <<<<<<<<<<<
app.db.DatabaseFile=f

The first one works because you’ve defined db as a local property. In the second one you’ve not created a new instance of SQLiteDatabase.

So it should be:

dbPath=“C:\Files\WarrantyAutomation\WarrantyAutomation”
f = New FolderItem(dbPath)
app.db = new SQLiteDatabase
app.db.DatabaseFile=f

Oops, Norman beat me to the punch.