[VB6] SQL Connecting: Runtime error 91
Hi,
I've been coding this server for a while with flat-file but I've changed to SQL now and I can't get connection working. :s please help.
http://i26.tinypic.com/2mzho9.jpg
The PanthaDB module code is:
Code:
Public zMGR_Connection As New ADODB.Connection
Public zMGR_Test As New ADODB.Connection
Public zMGR_Set As New ADODB.Recordset
Public zMGR_State As Boolean
Public LastError As String
Public checkConnectionResult As Boolean
Function checkConnection(serverHost As String, serverPort As Integer, serverDatabase As String, serverUsername As String, serverPassword As String) As Boolean
On Error Resume Next
zMGR_Test.Close
On Error GoTo errorConnection
zMGR_Test.ConnectionString = "Driver={MySQL ODBC 3.51 Driver};Server=" & serverHost & ";Port=" & serverPort & ";Database=" & serverDatabase & ";User=" & serverUsername & ";Password=" & serverPassword & ";Option=3;"
zMGR_Test.Open
zMGR_Test.Close
LastError = "no error nobo"
checkConnectionResult = True
Exit Function
errorConnection:
LastError = Error(Err)
checkConnectionResult = False
End Function
Function openConnection(serverHost As String, serverPort As Integer, serverDatabase As String, serverUsername As String, serverPassword As String)
On Error GoTo errorConnection
zMGR_Connection.ConnectionString = "Driver={MySQL ODBC 3.51 Driver};Server=" & serverHost & ";Port=" & serverPort & ";Database=" & serverDatabase & ";User=" & serverUsername & ";Password=" & serverPassword & ";Option=3;"
zMGR_Connection.Open
zMGR_Set.ActiveConnection = zMGR_Connection
zMGR_State = True
Exit Function
errorConnection:
zMGR_State = False
End Function
Function closeConnection()
On Error Resume Next
zMGR_Connection.Close
zMGR_State = False
End Function
Function checkExists(Query) As Boolean
On Error Resume Next
If zMGR_State = True Then
zMGR_Set.Open Query
If zMGR_Set.EOF = False Then checkExists = True
zMGR_Set.Close
End If
End Function
Function runQuery(Query As String)
On Error Resume Next
If zMGR_State = True Then
zMGR_Connection.Execute Query
End If
End Function
Function runRead(Query As String) As String
On Error Resume Next
If zMGR_State = True Then
zMGR_Set.Open Query
If zMGR_Set.EOF = False Then
MGR_TEMP = zMGR_Set.GetString
runRead = Left(MGR_TEMP, Len(MGR_TEMP) - 1)
End If
zMGR_Set.Close
End If
End Function
Re: [Help][Runtime error 91]VB6 SQL Connecting
make sure your vb6 is supporting mysql, use visual basic 2005 or 2008.
idk im sorry im coding in C++ :P
Re: [VB6] SQL Connecting: Runtime error 91
Project > Refrences > ActiveX Data Objects 2.5
If not search my name and look for the Holograph VB6 source i released and look at yours and their Holo/PanthaDB's and see if you can notice the problem!
Re: [VB6] SQL Connecting: Runtime error 91
hmm you haven't set 1 of the variables look through the code again closely.
Re: [VB6] SQL Connecting: Runtime error 91
I can't see a declaration for PanthaDB anyway, yet you're calling that class..
Try reading the error next time before making posts, it generally points out the obvious to you (And even highlights the error line for you)
Variable not set.
So check each variable there, for those that are declared and then finally one thats not!
Simple.
~ Jeax