I can verify that my VBA code is executing the stored procedure at the server but I'm unable to get the recordset back into Excel.
Set con = New ADODB.Connection
Set cmd = New ADODB.Command
Set rs = New ADODB.Recordset
con.Open "Provider=SQLOLEDB;Data Source=" & ServerName & ";...."//works
set rs = cmd.Execute(, SP_Param, adCmdStoredProc) // executes
If rs.EOF = False Then WSP1.Cells(4, 1).CopyFromRecordset rs
//tosses Operation is not allowed when the object is closed.
I've tried using the SQLOLEDB provider but am unable to get through to the stored procedure using that.
Relevant references:
Add a SET NOCOUNT ON to the beginning of your SQL Stored Procedure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With