Hello Everybody,
I am getting the following runtime error while retrieving data from SQL
Server stored procedure using ADO 2.6.
"Command text was not set for the command object" Run time error -
2147217908(80040e0c).Please let me know how can I resolve the error.
Thanks.
*****************************************
The follwing is my code:
Dim cnn As ADODB.Connection
Set cnn = New ADODB.Connection
Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
' Open the connection
cnn.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=False;Initial Catalog=master;Data Source=DC2019WK06960"
' Create the command
Set cmd.ActiveConnection = cnn
' Execute the Command
Set rst = cmd.Execute("sp_Surname_Dup")
Do Until rst.EOF
With Adodc1
.RecordSource = "sp_Surname_Dup"
.CursorType = adOpenStatic
.EOFAction = adDoMoveLast
.Caption = rst.RecordCount
'.Refresh
End With
rst.MoveNext
Loop
' Close the recordset
rst.Close
Set cmd = Nothing
set rst = Nothing
*******************************************