[RESOLVED] Close DB Connection (Type Mismatch)
I am getting a type mismatch on the highlighted. Do I need to set both the connection and recordset even though they are Dimmed public?
VB Code:
Public Sub CloseConnection()
'Set m_ADORs = New ADODB.Recordset
'Set m_ADOCon = New ADODB.Connection
If [hl]m_ADORs[/hl] = adStateOpen Then
m_ADORs.Close
End If
Set m_ADORs = Nothing
If m_ADOCon = adStateOpen Then
m_ADOCon.Close
End If
Set m_ADOCon = Nothing
End Sub
Re: Close DB Connection (Type Mismatch)
Don't you have to do
VB Code:
If m_ADORs.[b]State[/b] = adStateOpen Then
m_ADORs.Close
End If
That's just from memory, the property may be called something different.
Re: Close DB Connection (Type Mismatch)
The property name is State, that you need ti check. The reason why it is giving an error is because you are trying to compare an Object of ADODB.Connection type with an Integer.
Re: Close DB Connection (Type Mismatch)
Quote:
Originally Posted by pnish
Don't you have to do
VB Code:
If m_ADORs.[b]State[/b] = adStateOpen Then
m_ADORs.Close
End If
That's just from memory, the property may be called something different.
ohhhhh, ok! that makes a lot more sense!
Re: Close DB Connection (Type Mismatch)
i havent used that in a long time either, thats why i was trying to do it from memory and i missed the .State part. it now compiles with no error, thanks guys.