Connecting Tech Pros Worldwide Forums | Help | Site Map

Operation is not allowed when the object is closed

rrocket's Avatar
Member
 
Join Date: Aug 2007
Posts: 116
#1: Aug 26 '08
I am trying send information to the DB and the SP will return a recordset. The problem is that I keep getting this error (ADODB.Recordset error '800a0e78' Operation is not allowed when the object is closed). I saw a bunch of posts using queries, but none using SPs and cannot resolve the issue.

Here is a sample of the code... If more is needed let me know
Expand|Select|Wrap|Line Numbers
  1. Dim IsRate    Dim cmd
  2.     Dim rs
  3.  
  4.     Set cmd = createobject("ADODB.Command")
  5.     Set rs = createobject("ADODB.RecordSet")
  6.     with cmd
  7.         .ActiveConnection=gObjConnect
  8.         .CommandType=adCmdStoredProc
  9.         .CommandText="RateList_test"
  10.         .Parameters.Append .CreateParameter("@ZipFrom",adVarChar, adParamInput,6,mZipFr)
  11.         .Parameters.Append .CreateParameter("@ZipTo", adVarChar, adParamInput,6,mZipTo)
  12.  
  13. '........
  14.  
  15. .Parameters.Append .CreateParameter("@RateUsed", adInteger, adParamOutput,,0)
  16.         Set rs = cmd.Execute
  17.         IsRate = cmd.Parameters("@RateUsed")
  18.         response.Write rs.Status
  19.         end with
  20.         set cmd = nothing
  21.  
  22.     Dim sqlCar, RScar, SFlag    
  23.     SweeneyFlag = 0
  24.     if not rs.eof then '-->Fails here
  25.  
  26.  

rrocket's Avatar
Member
 
Join Date: Aug 2007
Posts: 116
#2: Aug 27 '08

re: Operation is not allowed when the object is closed


If this does not make sense or more info is needed, please let me know.

I guess what I am ultimately asking is how to open the rs connection when the command object is used.
rrocket's Avatar
Member
 
Join Date: Aug 2007
Posts: 116
#3: Aug 27 '08

re: Operation is not allowed when the object is closed


Anyone have a clue where I could be going wrong?
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#4: Aug 28 '08

re: Operation is not allowed when the object is closed


I don't use sp's as often as I should, but this is the most obvious (and easiest to troubleshoot) way to call it from asp:
Expand|Select|Wrap|Line Numbers
  1. query = "RateList_test " & firstInput & ", " & secondInput & ", " & nthInput
  2. 'response.write query 'for troubleshooting only
  3.  
  4. Set rs = gObjConnect.Execute(query) 'execute sql call
  5. 'or this last line could be
  6. 'rs.open query, gObjConnect 
The big advantage this has is you can print out the query, drop it into your query analyzer and see if it returns anything. When you use an ADODB.command I don't know of any way to print out or analyze the command it sends to the db. Anyway, let me know if this helps.

Jared
jhardman's Avatar
Moderator
 
Join Date: Jan 2007
Location: logan, utah
Posts: 2,690
#5: Aug 28 '08

re: Operation is not allowed when the object is closed


btw, many of our experts search for unanswered posts, so replying to your own thread probably hurt your chance of getting an answer. Sending a polite PM to one of the forum experts asking them to look into your thread (which you did) is just fine.

Jared, moderator
Reply