Bad Connection String
Hello,
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
Next
cnn.Close
|