troubleshooting Question

Invalid Use of Null error because value from MySQL Server doesn't last

Avatar of rhaak
rhaak asked on
MySQL ServerVisual Basic Classic
8 Comments2 Solutions477 ViewsLast Modified:
I am getting an Invalid use of Null error at the following line in the attached code from a VB6 application:
sAddress = MyRS!Address
However, I do have a check for Null.  I put a stop point in the code, and the first time I hilight MyRS!Address it contains a value.  I then move the mouse away and move it back without stepping through any code, and now MyRS!Address is Null.  The same thing must be happening when application is run; at the IsNull statement MyRS!Address is not Null, but the the second time it is referenced a few lines later the value is Null.  Any suggestions as to why this is happening???  Could there be a problem at the MySQL server?

Thanks in advance!
Dim MyDB As ADODB.Connection
Set MyDB = New ADODB.Connection

MyDB.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=myserver;DATABASE=mydatabase;UID=myuid;PWD=mypwd"
MyDB.Open

Dim MyRS As ADODB.Recordset
Set MyRS = New ADODB.Recordset

SQLPARM = "Select * from USERS Where id = 5"

Set MyRS = MyDB.Execute(SQLPARM)

If Not MyRS.EOF And Not MyRS.BOF Then
	If IsNull(MyRS!Address) Then
		sAddress = ""
	Else
		sAddress = MyRS!Address
	End If
End If
                           
MyRS.Close
Set MyRS.ActiveConnection = Nothing

Open in new window

ASKER CERTIFIED SOLUTION
Karen
Analyst programmer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros