
Data objects closed error in ADO 2.1 and SQL server 6.5
Hi,
I am using ADO 2.1 to access the recordset returned by a stored
procedure on SQL server 6.5 and encountered the following error message:
"The operation requested by the application is not allowed if the
object is closed."
The problem only occured after I extended my original stored procedure,
which was a simple select statement (with group by) inside a dynamic
execution. The extension I needed was to modify some of the data from
that select in order to perform another aggregation (sum). In short,
Original Stored Procedure:
Select ... From ... Where ... Group By ...
Extended Stored Procedure:
(1) Select ... From ... Into #TMP Where ...
(2) Declare a cursor to go thru the whole of #TMP to extract specific
data that I needed to update on.
(3) Close and deallocate the cursor.
(4) Select ... From #TMP Where ... Group By ...
Both the original stored procedure and the extended one worked
perfectly in iSQL and gave identical results (when the data did not
actually need any modification). However, accessing the result set
from a DLL (via ADO 2.1) bombed on the extended stored procedure (but
not the original).
From my previous experience with this particular error message, I
suspect that the extended stored procedure is somehow returning
multiple result sets, the first of which is empty and thus considered
closed by ADO. However, this "phantom" result set is not visible in
the iSQL window and I cannot pinpoint where it could have come from.
Does anyone have any idea what is going on? Could the "Select ... Into
#TMP ..." somehow is returning an empty result set?
Thanks for any help or advice that you can offer.
Albert Yu
newsgroup, thanks.
Sent via Deja.com http://www.*-*-*.com/
Share what you know. Learn what you don't.