Monday, March 19, 2012

Cannot obtain recordset from stored procedure that contains Exec c

Hopefully someone can help. Using vbscript and ADO, I can call a very simpl
e
stored procedure that returns a recordset w/o any problems. However, when I
call a stored procedure that stuffs records into another table using a SQL
string built and the Exec command and then select the records from that
table--ADO always reports the recordset is closed.
The stored procedure works fine in Query Analyzer. It also doesn't matter
if table is temp or permanent. My workaround is to first call the stored
procedure followed by a second call to get the records. My goal is to use a
temp table in the stored procedure.
Psuedo code of stored procedure (which also uses cursor):
declare @.sqlstr varchar (100)
set @.sqlstr = 'insert into tmptable select field from anothertable'
exec(@.sqpstr)
select * from tmptableAre you setting SET NOCOUNT ON at the begining of the sp?
AMB
"reedholm" wrote:

> Hopefully someone can help. Using vbscript and ADO, I can call a very sim
ple
> stored procedure that returns a recordset w/o any problems. However, when
I
> call a stored procedure that stuffs records into another table using a SQL
> string built and the Exec command and then select the records from that
> table--ADO always reports the recordset is closed.
> The stored procedure works fine in Query Analyzer. It also doesn't matter
> if table is temp or permanent. My workaround is to first call the stored
> procedure followed by a second call to get the records. My goal is to use
a
> temp table in the stored procedure.
> Psuedo code of stored procedure (which also uses cursor):
> declare @.sqlstr varchar (100)
> set @.sqlstr = 'insert into tmptable select field from anothertable'
> exec(@.sqpstr)
> select * from tmptable
>

No comments:

Post a Comment