Results 1 to 5 of 5

Thread: [RESOLVED] Close DB Connection (Type Mismatch)

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Resolved [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:
    1. Public Sub CloseConnection()
    2.     'Set m_ADORs = New ADODB.Recordset
    3.     'Set m_ADOCon = New ADODB.Connection
    4.    
    5.     If [hl]m_ADORs[/hl] = adStateOpen Then
    6.         m_ADORs.Close
    7.     End If
    8.    
    9.     Set m_ADORs = Nothing
    10.    
    11.     If m_ADOCon = adStateOpen Then
    12.         m_ADOCon.Close
    13.     End If
    14.    
    15.     Set m_ADOCon = Nothing
    16. End Sub

  2. #2
    Frenzied Member pnish's Avatar
    Join Date
    Aug 2002
    Location
    Tassie, Oz
    Posts
    1,918

    Re: Close DB Connection (Type Mismatch)

    Don't you have to do
    VB Code:
    1. If m_ADORs.[b]State[/b] = adStateOpen Then
    2.         m_ADORs.Close
    3.     End If
    That's just from memory, the property may be called something different.
    Pete

    No trees were harmed in the making of this post, however a large number of electrons were greatly inconvenienced.

  3. #3
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    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.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: Close DB Connection (Type Mismatch)

    Quote Originally Posted by pnish
    Don't you have to do
    VB Code:
    1. If m_ADORs.[b]State[/b] = adStateOpen Then
    2.         m_ADORs.Close
    3.     End If
    That's just from memory, the property may be called something different.
    ohhhhh, ok! that makes a lot more sense!

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width