Mysqldatabes with Web

I running Xojo 2021r2.1 on Linux.
I am not sure why this is not working… I have looked at the Eddies Electronics, but no joy.
I have declared in my session module the database:

dim vaccounting As New MySQLCommunityServer
vaccounting.Host = “192.168.1.52”
vaccounting.DatabaseName = “vaccounting”
vaccounting.UserName = “My User Name”
vaccounting.Password = “My Passwword”

If vaccounting.Connect Then
Else
'MessageBox “trying to connect”
End If

I know it connects… that is not a problem. When I try to access it on a web page my recordset is empty and I have a nil object error. The txtUname.Text does show the correct username, and the strSql line is correct. It seems that it is not using the session.vaccounting database? Not sure what I have wrong here?

Dim strSql as String
strSql = (“Select * from license where uname = '”+ txtUName.Text + “’”)
dim rstUsers as RecordSet
rstUsers =Session.vaccounting.SQLSelect(strSql)

Dim pwcheck as string
pwcheck = rstUsers.Field(“PWord”).StringValue

If txtPWord.Text <> pwcheck then
MessageBox “Sorry, wrong password”
Session.Quit
Else
End if

Your earlier connection is probably going out of scope in the session. Try connecting in the same method you are doing the query.

Make vaccounting a property of Session and create the instance in Session.Opening.

dim vaccounting As New MySQLCommunityServer

becomes

vaccounting = New MySQLCommunityServer

1 Like