SQLite db closes direct after it was opened

I have an windows desktop application which runs good for years. I am adding/changing modules in the application, but suddenly it has a db error in a part I have not touched for years. I tried older saves too, but they got the same error. The weird thing is that the db let itself open well, and after a check if the db is op, the db closes.

f = GetFolderItem(gPathDB+"DTS.db",3)
db = new SQLiteDatabase
db.DatabaseFile=f

if db.Connect = true then
  ExecSql = "SELECT * from Disaster where dDate like '"+MyDate+"%' and dType = 'vu' and dRetPeriod > "+str(RetVUPer)
  rs = db.SQLSelect(Execsql)
  
  if rs.Field("dEvtCode").Value = Nil then
    if d.month =1 then
      ExecSql = "SELECT * from Disaster where dDate like '"+str(d.year-1)+"12' and dType = 'vu' and dRetPeriod > "+str(RetVUPer)
      rs = db.SQLSelect(Execsql)
    else
      ExecSql = "SELECT * from Disaster where dDate like '"+str(d.year)+str(format(d.month-1,"00"))+ "%' and dType = 'vu' and dRetPeriod > "+str(RetVUPer)
      rs = db.SQLSelect(Execsql)
    end if
  end if

After the “if db.Connect = true then” I see this:

and it continues till th ers statement and then I do get an “database disk image is malformed”

When I check the database with SQLite browser I can do everything. When I execute in de browser the statement as created in the code, the statement shows the record.

The weird thing is that it happened suddenly. Before today it did run like a charm.

I tried also to run the app. on a copy of the db on another disk, but same result.

I use:

Edition Windows 11 Pro
Version 23H2
Installed on ‎3-‎6-‎2024
OS build 22631.4751
Experience Windows Feature Experience Pack 1000.22700.1055.0

and HW:
|—|—|
|Processor|Intel(R) Core™ i5-6600K CPU @ 3.50GHz 3.50 GHz|
|Installed RAM|16,0 GB|
|Device ID|18FBF0B0-420C-4D12-8A36-C6F3715093DC|
|Product ID|00330-80000-00000-AA348|
|System type|64-bit operating system, x64-based processor|
|Pen and touch|No pen or touch input is available for this display|

Just a guess as you did not say which version you are using: newer version of Xojo throw an exception if db.connect fails, they don’t return a boolean anymore…

I am using Xojo 2024 v4.1 since it was released. Gave also not a problem till today.

Seems that the database was corrupted for xojo, but not for SQLite browser. In the browser no problems were found. In xojo it could not acces the database anymore.
I did an export to csv of the concerned table, loaded back a backup of the database from december, deleted the table from that copy database and imported the csv. Now the application is running without problem.
No clue why the database was damaged.

Did you try looking at the db using the sqlite3 CLI program? That’s always the best best - written by the same folks.

No, but I thought the dbBrowser was also from them. I will do when it happens again. I deleted the problem database already. Is there a limit of stored records for SQLite? One table contains now >550.000 records. Should not be that much for a database.

The SQLite project provides the library and a CLI. Nothing else.

550k records is orders of magnitude below the limits, which you can explore here:

https://www.sqlite.org/limits.html

1 Like