Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

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

Avatar of rhaak
rhaak asked on
Visual Basic ClassicMySQL Server
8 Comments1 Solution477 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
ASKER CERTIFIED SOLUTION
Avatar of Karen
KarenFlag of Australia imageAnalyst programmer

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

Commented:
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answers