Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Returning recordsets from Stored Procs


Message #1 by ckoski@w... on Fri, 19 May 2000 17:30:39 -0400
Hi all,



I've got a function that I'm trying to return a "disconnected" recordset

from...  well whatever I try, I can't make the final disconnection without

ending up closing the recordset (which is not what I want)...  here's my

code:



<!--#include file="i_adovbs.asp" -->

<%

Class Business

 Private DSN, dbConnection



 ' -- PRIVATE --

 Private Sub Class_Initialize

  DSN = "DSN=Database;"

  set dbConnection = Server.CreateObject("ADODB.Connection")

  dbConnection.CursorLocation = adUseClient

  dbConnection.Open DSN

 End Sub



 Private Sub Class_Terminate

  dbConnection.Close

  set dbConnection = Nothing

 End Sub



 Public Function GetListing(content_id)

  Dim objDictionary

  set objDictionary = Server.CreateObject("Commerce.Dictionary")



  if not Exists(content_id) then

   set GetListing = objDictionary

  else

   Dim rsListing, cmd

   set cmd = Server.CreateObject("ADODB.Command")

   set cmd.ActiveConnection = dbConnection

   cmd.CommandType = adCmdStoredProc

   cmd.CommandText = "bus_getlisting"

   cmd.Parameters.Append cmd.CreateParameter ("contentid", adInteger ,

adParamInput, , content_id)

   set rsListing = server.CreateObject("ADODB.Recordset")

   rsListing.CursorLocation = adUseClient

   set rsListing = cmd.Execute

   set objDictionary.rsListing = rsListing.Clone(adLockReadOnly )

   rsListing.close

  end if



  set GetListing = objDictionary

 End Function



 Public Function Exists(content_id)

  Dim cmd



  set cmd = Server.CreateObject("ADODB.Command")

  With cmd

   .ActiveConnection = dbConnection

   .CommandType = adCmdStoredProc

   .CommandText = "bus_listingexists"



   .Parameters.Append .CreateParameter ("Return_Value", adInteger,

adParamReturnValue)

   .Parameters.Append .CreateParameter

("contentid",adInteger,adParamInput,,content_id)

   .Execute

  end with

  Exists = CBool(cmd.Parameters("Return_Value"))

  set cmd = nothing



 End Function



End Class





Dim temp, id, item

set temp = New Business



set temp2= temp.GetListing (50)

set temp = Nothing



if not temp2.rsListing.EOF then

 Response.Write "Record found (no probs)"

else

 Response.Write "No record pulled in"

end if

%>





The record 50 can be found, but temp2.rsListing disconnects and I am left

with nothing in the recordset

I get this error:



ADODB.Recordset error '800a0e78'



Operation is not allowed when the object is closed.



...



I need to figure out how to disconnect a recordset AFTER I populate it with

data from a stored procedure...



Any thoughts?



TIA,





**************************************************

Cory Koski

Website Programmer

Wabang Creative Technology

Brainbench e-certtified Master ASP programmer

(xxx) xxx-xxxx








  Return to Index