Object Variable or With Block Variable Not Set

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smartchap
    New Member
    • Dec 2007
    • 236

    Object Variable or With Block Variable Not Set

    Code:
    Dim cnnADO      As New ADODB.Connection
    Dim rstData     As New ADODB.Recordset
    Dim strCustomer As String
    Dim strSQL      As String
    Dim strFileName As String
    
    On Error Resume Next
    
        'Set up the connection
        With cnnADO
            .ConnectionString = "Provider=SQLOLEDB.1;" & _
                                "Password=;" & _
                                "Persist Security Info=True;" & _
                                "User ID=sa;" & _
                                "Initial Catalog=C:\Program Files\Microsoft Visual Studio\VB98\Nwind;" & _
                                "Data Source=MyServer"
            .Open
        End With
    In above code when debugging found that after .Open cnnADO is set equal to the string "Provider=....M yServer". But as soon as control passes End With, cnnADO is equal to "<Object Variable or With Block Variable Not Set.>".

    What is the cause please help me.
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    check if you have included proper library (from references)

    Comment

    • smartchap
      New Member
      • Dec 2007
      • 236

      #3
      Thanks changed reference from MSADO 2.6 Library to MSADO 2.8 Library. Now it works.

      Comment

      Working...