I am trying to populate a listbox with data from an SQLite database and am getting a runtime error that I cannot catch or debug.
Not sure if the data is corrupt.
I have a client with an older MS Access application that they want converted to the web. So I used a tool that would convert the .accdb to an SQLite database.
I can open the SQLite database with Xojo, and get a list of the tables. But when I try to load the table data in a list box … some tables load, and some go BOOM.
I tried the new RowSet structure - it worked sometimes, and sometimes the app crashes with an runtime error.
So I switched back to using a RecordSet and … same issue.
When the database is opened a popupmenu gets the list of the tables in the database AND the ListBox.ColumnCount is set to match the column count of the table.
This seems to be working.
But when I click my button to populate the list box, sometimes JOY and sometimes no joy - a runtime error crashes my webapp.
This routines seems to be where the error is.
I tried this with and without the Try…Catch block.
If rs <> Nil Then
While Not rs.EOF
// For I = 1 To rs.FieldCount <----------- Tried to limit the bounds to the FieldCount
For I = 0 To ListBox1.ColumnCount-1 // <— Figured I’d try to limit the bounds a different way
Listbox1.Cell(Listbox1.LastIndex, I) = rs.IdxField(I + 1).StringValue
Catch e As NilObjectException
Catch e As RunTimeException
MessageBox(“An exception of type " + e.Message + " was caught.”)
So … should this work, or do I have some database corruption from the client. (I’m sure all clients give us perfect databases with no bad data ever).
The conversion software did not catch table names with spaces. But that was easy enough to fix with an SQLite database editor.
Like I say, some tables load without issues. But others cause a runtime error.
If I replace this code (below) … NO error.
S= rs.IdxField(I + 1).StringValue
// Listbox1.Cell(Listbox1.LastIndex, I)=S
But if I uncomment that line … boom.
So I assume there is some data that is causing the listbox to choke on the data to be imported.
Any help would be a great.