Lots to learn, missing a step somewhere with sqlite

Ok, old time (also old) coder here, I am trying to convert a application written by me in Vb.net, actually first written in Fortran on a VaxVMS using RDB database, that is how old I am at this. So not new to coding and having an issue just starting out with Xojo. I have converted my Oracle database to sqlite and I am trying to create a web app on Mac OS. I have it opening the database, using build copy files I move it and now no longer getting an error at runtime about db not found. But in main window, all I have right now is one text field, I just want to execute a super simple SQL statement and get a item from a record, really don’t care what, I just want to confirm database is really open in main window. My SQL statement is just Select item_shortname from item, can’t get any simpler. I keep failing on the if not db.connect statement so it’s obvious the variable DB that was set in the session opening method is not global. Do I need to declare it in a module for it to be global ? do I need to re-open the database every time I want to execute a SQL statement ? I do have the actual open db code in a session method called from session opening.

I needed a property to get things going that I was missing but still not working. Here is my code

dim sql as string
sql = “Select item_shortname from item”

Catch error As DatabaseException
MessageBox("DB Error: " + error.Message)
End Try

I fail on the DB command, it’s a nil object, I still want to put the one variable I return into text field nametest but nametest.text is not my issue yet.

this is super basic at this point and I seem to be stuck, but just wait until I start asking how to convert my windows DLL’s to Mac with Xojo, I know there is no concept of DLLs, so I think I have put all the subs and functions into a module, but first lets get it connected to database.

I can’t seem to edit original message, My code is now
dim sql as string = “Select item_shortname from item”
dim data as RowSet

if not DB.Connect then
messagebox("unable to connect to database " + DB.errormessage)
end if

data = DB.ExecuteSQL(sql)
Catch error As DatabaseException
MessageBox("DB Error: " + error.Message)
End Try

I fail on the DB.Execute with

There is more than one method with this name but this does not match any of the available signatures.

ExecuteSQL does not return anything.

Perhaps you want SelectSQL instead, which returns a RowSet.

Thank You, WOW, this hello world took several hours (hello world is what I got from the DB), now loading the real data in DB and it’s working for all the fields.

Now to start converting my vb.net code.

1 Like