
Error using Command Object
Could somebody help ???
I wrote the following small test program and got the following error:
"the rowset was built over a live data feed and cannot be restarted"
i'm pasting the code that generated this. The line that raised this
error is the one with the "rs.MoveFirst" in it...
TIA
Private Sub Command1_Click()
Dim cn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim prm As ADODB.Parameter
Dim rs As ADODB.Recordset
cn.Open "dsn=tst1", "sa"
Set rs = New ADODB.Recordset
Set cmd.ActiveConnection = cn
cmd.CommandText = "tst2"
cmd.CommandType = adCmdStoredProc
Set prm = cmd.CreateParameter("a", adInteger, adParamInput, 5)
cmd.Parameters.Append prm
cmd("a") = 2
Set rs = cmd.Execute
If rs.EOF And rs.BOF Then
MsgBox "RS is empty !!!"
Else
rs.MoveFirst
Do Until rs.EOF
Debug.Print rs.Fields(0) & " " & rs.Fields(1)
rs.MoveNext
Loop
End If
MsgBox "END !!!"
'cmd.close
'Set cmd = Nothing
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub