View Single Post
  #1 (permalink)  
Old May 8th, 2008, 07:16 PM
paulcbyrum paulcbyrum is offline
Registered User
Join Date: Apr 2008
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Bad Connection String


I have SQL Server and a VBA Access application. I also have a ODBC System DSN data source named LAVA. The connection test is good. However, when I use ADODB to connect, connection appears to be opened, but I get a "Operation is not allowed when object is closed". Any suggestons? Here is the code:

   Dim rst As ADODB.Recordset
   Dim cnn As ADODB.Connection

    Set cnn = New ADODB.Connection
    cnn.Open "DSN=LAVA;"

    Set rst = New ADODB.Recordset
    rst.Open "GIS_Data", cnn, adOpenForwardOnly, adLockReadOnly

    Dim fld As ADODB.Field
    For Each fld In rst.Fields
        Debug.Print fld.Name


Reply With Quote