Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asptoday_discuss thread: True Disconnected ADO Recordset


Message #1 by "Angshuman Paul" <angs_paul@h...> on Mon, 15 Apr 2002 06:01:31
' This function returns a true disconnected ADO recordset to client

Public Function Execute_Usp_Sel_All_Dropdown(ByVal content_set_id As 
Integer) As ADOR.Recordset
    '**********************************************************************
    ' FUNCTION          :   Execute_Usp_Sel_All_Dropdown
    ' DESCRIPTION       :   Execute SP usp_sel_all_dropdown to fill   
    '                       select dropdowns  
    ' SP NAME           :   usp_sel_all_dropdown
    ' RETURN PARAMETERS :   ADOR.Recordset
    '**********************************************************************
    On Error GoTo ErrHandler

    Set Execute_Usp_Sel_All_Dropdown = Nothing
    
    'Declaring all ADO Object and variable
    Dim sParamName As String
    Dim objConn As ADODB.Connection
    Dim objCmd As ADODB.Command
    Dim objReturnRs As ADOR.Recordset
    
    'Initialize required object
    Set objCmd = New ADODB.Command
    Set objReturnRs = New ADOR.Recordset
    
    'Set the Command Object properties
    sParamName = "@content_set_id"
    objCmd.Parameters.Append objCmd.CreateParameter(sParamName, adInteger, 
adParamInput, , content_set_id)
    objCmd.CommandType = adCmdStoredProc
    objCmd.CommandText = "usp_sel_all_dropdown"
    
    'Set the Recordset Object properties
    objReturnRs.CursorLocation = adUseClient
    objReturnRs.CursorType = adOpenForwardOnly
    objReturnRs.LockType = adLockReadOnly
    
    'Set a open Connection from function Get_Connection and set it to 
Command Object
    Set objConn = Get_Connection
    Set objCmd.ActiveConnection = objConn
    
    'Open the Recordset Object with Command Object as the source parameter
    objReturnRs.Open objCmd
    
    'Close the ActiveConnection of the Recordset Object to get a true 
disconnected recordset
    Set objReturnRs.ActiveConnection = Nothing
    
    'Return the disconnected Recordset Object
    Set Execute_Usp_Sel_All_Dropdown = objReturnRs
    
Cleanup:
    ' Close and set all objects to Nothing
    objConn.Close
    Set objConn = Nothing
    Set objCmd = Nothing
    Set objReturnRs = Nothing
    
    Exit Function

ErrHandler:
' Handle if any error
End Function

  Return to Index