ASP Problem
Tuesday, March 19, 2002 by Elfkura | Discussion: WinCustomize Talk
Operation Cannot Be Performed While Recordset is Closed.
I'm not sure what to do about this error but I have:
-made sure the dll is registered locally
-verify the sql syntax
-double check spelling
the dll does work for a different function which also queries the sql server. If anyone knows, please email me.
[email protected]
Thanks
Reply #2 Tuesday, March 19, 2002 9:15 PM
--------------------------------------------
Function DoIt(rst as Variant) as String
Dim strSQL as String
Dim SQLConn as ADODB.Connection
strSQL="select username, userid from accounts"
OpenConnection SQLConn
rst=GetRecords(strSQL, SQLConn)
CloseConnection SQLConn
'error handling feature goes here.... it works though
End Function
---------------------------------------------
The OpenConnection, CloseConnection, and GetRecords are custom made functions that I use frequently and I KNOW there is no problem regarding those.
The ASP looks like:
----------------------------------------------
dim obj, rst, errors
set obj=Server.CreateObject("MyDLL.IDB")
set rst=Server.CreateObject("ADODB.Recordset")
errors=obj.DoIt(rst)
if not (errors "")
redirect to error page
else
response.write ""
rst.MoveFirst()
While not rst.EOF do
response.write ""
response.write rst("username")
response.write ""
response.write rst("userid")
response.write ""
loop
response.write "
end if
---------------------------------------------
That's pretty much all that happens. I know that the SQL statement DOES return records, and that the DLL is registered locally.... I do this twice in the page. the first time it works, but when I add the 2nd Function call (a different function) the page errors out on the line: "rst.MoveFirst()" (I bolded it too) with the error - Operation cannot be performed while the object is closed....
I'm running out of ideas on what to do here, so if anyone knows, I'd appreciate the help.
-Rob
Reply #3 Tuesday, March 19, 2002 9:16 PM
uumm..... sorry it looks like crap now... I even did the indenting and spacing to make it look all nice and stuff....

Reply #4 Tuesday, March 19, 2002 11:17 PM
So you're saying that in previous cases, you've been able to enumerate through the recordset AFTER its corresponding connection has been closed?
I've always thought that a recordset created from a connection is normally a live object and that closing the connection also closes the recordset. I've always closed the connection AFTER I was done with the recordset. I know you can have a client-side recordset (with RDS I think) but I'm not sure how that works. Or maybe changing the cursor type not to use server-side cursors (if thats even relevant).
Reply #5 Wednesday, March 20, 2002 9:11 AM
nope, the cursors don't effect anything here.
I've used this same system for some time now, and it's always worked (with closing the DB connection after the query). I've seen this error before when runnning a Stored Procedure (I fixed by putting "NO COUNT ON" at the beginning of the Procedure and "NO COUNT OFF" at the bottom). I've also seen this error come up if the query returns 0 records, but I know it's returning 6, b/c I've testted it in the query analyzer('isqlw' for SQL Server users).
The thing that pisses me off the most is the fact that 1 function in the DLL, which looks damn near IDENTICAL to the one above works fine, but the other one, which ALSO looks damn near IDENTICAL to the one above doesn't work and returns a Closed Recordset.
A friend hs given me a few suggestions, so I'm going to try those and hopefully it'll fix this, I'll messsage back here should I solve this.
Please login to comment and/or vote for this skin.
Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:
- Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
- Access to a great community, with a massive database of many, many areas of interest.
- Access to contests & subscription offers like exclusive emails.
- It's simple, and FREE!







Reply #1 Tuesday, March 19, 2002 7:55 PM