ADODB.Recordset error '800a0e78' Operation is not allowed when the object is closed. - ASP

milani_lucie
milani_lucie used Ask the Experts™
on
Hi,

I am getting that error. Here is the code:

dim Kcn, Krs

set Kcn = server.CreateObject("ADODB.Connection")

Kcn.ConnectionString = "server=Personal;uid=Sam;pwd=Password;provider=SQLOLEDB;database=Sample"

Kcn.OPEN

set Krs = Kcn.execute("EXEC uspSample")  // "uspSample" is stored procedure name

do while not Krs.EOF  // Error here

loop

Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2011
Commented:
Try:

<% 
Option Explicit 
Response.Buffer = True 

dim Kcn, Krs, sql

' This how you call a Stored Procedure ..... 
sql = "EXECUTE uspSample"

set Kcn= server.createobject("adodb.connection")
Kcn.Open "Server=Personal;uid=Sam;pwd=Password;provider=SQLOLEDB;database=Sample"

set Krs = Kcn.Execute(sql)
do while not Krs.eof
    response.write Krs("yourFieldname") & "<BR>"
   Krs.movenext
loop 
Krs.close
Kcn.Close
set Krs = Nothing 
set Kcn = Nothing 
%>

Open in new window

Author

Commented:
Still, i am getting the same error. Any help ?

Thanks
Top Expert 2011

Commented:
ok, let me test.

be back....

OK, I just tested it and it worked fine.

Are you sure you are using the code I posted?
Expert of the Year 2014
Top Expert 2014
Commented:
Try SET NOCOUNT ON at the beginning of your stored procedure

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial