Hello,
The runtime error 3001 is being generated on the line
I have tried several of the locktypes and they are produce the same error. I can't seem to figure out what I am doing wrong. I am using late binding so I can learn how to do this.
The runtime error 3001 is being generated on the line
Code:
ADOrs.lockType = adLockReadOnly
Code:
Public Sub ADOtest()
Dim ADOconn As Object
Dim ADOrs As Object
Set ADOconn = CreateObject("ADODB.CONNECTION")
Set ADOrs = CreateObject("adodb.recordset")
ADOconn.ConnectionString = "Driver={SQL Server};Server=VA10PWVSQL353\SQL01,10001;Database=CRA;Trusted_Connection=Yes;"
ADOconn.Open
Do While ADOconn.state <> 1
DoEvents
If ADOconn.state = 0 Then
Exit Sub
End If
Loop
'Debug.Print ADOconn.state
Set ADOrs.activeconnection = ADOconn
ADOrs.lockType = adLockReadOnly
ADOrs.Source = "select * from zzzzCMS_DIY_DIAG"
ADOrs.Open
If Not ADOrs.EOF Then ADOrs.MoveFirst
Do Until ADOrs.EOF
Debug.Print ADOrs("ICD")
ADOrs.MoveNext
Loop
ADOconn.Close
ADOrs.Close
Set ADOconn = Nothing
Set ADOrs = Nothing
End Sub