I’m pretty new to Xojo and I’m trying my hand at a small web app that I’m going to run here at home. I added an app-wide property called db and defined it as an SQLIteDatabase. It’s a public property. Then, I went into my Session.Open() event and added this code:
Dim db as new SQLiteDatabase
db.DatabaseFile = GetFolderItem(“mydatabase.sqlite”)
if db.Connect() = false then
MsgBox("Connection to the database failed. " + db.ErrorMessage)
Now, I have a form called MainWindow and in that window I have a button called “SigninButton”. In that buttons Action() event, I have the following code:
Dim rs as RecordSet
rs = Session.db.SQLSelect(“SELECT username FROM users WHERE username=’” + trim(UsernameField.Text) + “’”)
if rs.RecordCount > 0 then
I know that the session is connecting to my database properly because it’s not displaying the error message. When I remove the database file from the expected location, it throws an error. But, for some reason, when I try to access the database and query it, I get a NilObjectException.
Anyone know why? How should I properly access a database in the web edition.
Thanks a lot!