nilobjectexception

Hello,

I have a web application, accessing a database, which has been working fine for several months. I originally developed under Real Studio 2012r1.2, running in Windows 7. At a point where it seemed I downloaded the first release of Xojo, I started getting a nilobjectexception when checking a Recordset.RecordCount. While I had installed Xojo, I was still using 2012r1.2, as I hadn’t renewed by db and web app licenses yet.

Here’s the relevant code, with a few things changed to protect the innocent :slight_smile: :

Under App, I created a custom property:
DomtrackerDB As MySQLCommunityServer

In my App Open Event:
[b] DomtrackerDB = New MySQLCommunityServer

DomtrackerDB.Host = “127.0.0.1”
DomtrackerDB.Port = 3306
DomtrackerDB.DatabaseName = “databasename”
DomtrackerDB.UserName = “username”
DomtrackerDB.Password = “password”[/b]

I have a login page, with a username text field and a password text field, and a login button.

Here’s the code for the login action event:

[b]Dim userResults As RecordSet
Dim selectQuery As String

MsgBox “Just before the SQL Select”

selectQuery = “select firstName from users where username=’” + txtUsername.Text + “’ and password = MD5(’” + txtPassword.Text + “’)”

userResults = App.DomtrackerDB.SQLSelect( selectQuery )

MsgBox “Just AFTER the SQL Select”

if App.DomtrackerDB.Error then
MsgBox "There was an error trying to query the database: " + App.DomtrackerDB.ErrorMessage
else
MsgBox “There seemed to be no error querying the database”
end if

if userResults.RecordCount > 0 then
Me.Close
Main.Show
else
MsgBox (“Invalid Username or Password”)
end if[/b]

When I run the app, enter the username and password, then click my login button(as I’d always done), the editor immediately highlights ‘userResults.RecordCount’ with the nilObjectException. I tested the SQL code at the MySQL command line, and it returns a single record, as it should.

I understand the meaning of nilOjbectException; I just don’t understand why it’s showing up now, when this code has been working fine all along. My only hypothesis is that when I installed Xojo, something in one of the librarys ‘crept’ into my 2012r1.2 installation? This may be irrelevant at this point as I’m running the code under Xojo 2013r2 now (licenses for web and database have been renewed) and having the same problem.

Thoughts? Suggestions?

Thank you,

Steve

I can’t see any DomTracker.db.connect in the above code, but perhaps that’s just not transcribed. If you put error checking after the SQLSelect line does that show any db errors?

Thanks, Wayne. That solved it!

Now, I just need to figure out how I deleted it to begin with… :stuck_out_tongue:

Including the Domtracker.db.connect solved it, that is…