get recordset from cmd object



I would like to return a recordset from a stored procedure using the cmd

Set mCmd = New ADODB.Command
With mCmd
.ActiveConnection = mConn
.CommandText = SelectCommandText
.CommandType = adcmdStoredProc
Set mrst = New ADODB.Recordset
Set mrst = .Execute

I get an error "syntax error or access violation" when I try to execute. I
have code that checks whether mConn is open prior to this and it is. When I
take the .CommandText and run it in Query Analyzer, it executes fine. What
can I do to determine what the issue is?

Thanks so much!

Douglas J. Steele

Assuming that mConn is an instantiated Connection object, you need

Set .ActiveConnection = mConn

In actual fact, you don't need the Set mrst = New ADODB.Recordset statement,
as the next line should properly instantiate mrst.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question