SQLiteDatabase: not Nil, but…

I checked against db = Nil, and after RS = db.SQLExecute,
le Database instance is unexpectedly Nil… (sic) as the debugger says…

I opened App.gCaritasDB and saw ErrorMessage there:
“Database instance is unexpectedly nil.”

Error code 1.

Relevant code:

// Simple check
If App.gCaritasDB = Nil Then
  MsgBox MethodName + "SQLiteDatabase est Nil."
  Return True
End If

// Remplit la commande SQL
sql_parms = "SELECT * FROM Secours_Populaire ORDER BY CAST(Casier AS INTEGER);"

// Demande un tri numérique sur la colonne Casier
SQLite_RS = App.gCaritasDB.SQLSelect(sql_parms)
If SQLite_RS = Nil Then

This code is in ListBox1.SortColumn (for Column 0)…

MacOS Monterey / Xojo 2021r2.1 / API1

About the database:
a. the .sqlite file exists and is populated,
b. the TABLE exist and is populated,
c. a Column named Casier exist and is populated… (with numeric value 1 to 575)

In the front window, I have that ListBox populated with that .sqlite file content already loaded.

I am starting to eat my hat. I also am asking myself about removing this sort feature…

Did you call connect somewhere?

Also, you should be catching DatabaseExceptions when calling SQLSelect.

1 Like

using API 1 ?

NB: using my 2014 i5 MBP /+ El Capitan, I found a way to use correctly the feature, in the IDE. Once I built the application, it started to dizzle… (stop working)…
The workaround was … clears the ListBox, add one Row, Delete that Row, and SQL Sort/Add data from .sqlite. (no danse was included)

And this was designed in a small application, under the same conditions:

a. display the .sqlite file into the ListBox,
b. sort the ListBox when click on Column(0) or Column(1) with a SQLSelect in SortColumn and (clears, then) repopulate the ListBox with the correctly, numerically sorted data.

You are correct. I was thinking of the newer methods.

Thank you.

On the other hand, I will check if I have another valid instance of db (global SQLiteDatabase)…

I noticed that I cannot trash the .sqlite file on Windows 10 when the application is running. I can do what I want when running on MacOS (El Capitan / Ventura). While creating the data base file / adding TABLEs, I changed my mind many times with some Column names (dbOwner column vs dbUser column for example), and so I trashed many times the .sqlite file (with the application running both in the IDE and / or as stand alone) and modify my code, executing it, modify, etc.