Disconnected Record Set example

Results 1 to 2 of 2

Thread: Disconnected Record Set example

  1. #1
    Join Date
    Dec 1969

    Default Disconnected Record Set example

    Hi I am using the example at 4guys on Disconnected recordset. I am trying to put the recordset into an array. But I get "operation not allowed when the recordset is closed....Here is the code snippet...<BR><BR>Function GetRS(strSQL)<BR>&#039;this function returns a disconnected RS<BR><BR>&#039;ADO Constants<BR>Const adUseClient = 3<BR>Const adLockBatchOptimistic = 4 <BR>Const adLockReadOnly = 1<BR>Const adLockPessimistic = 2<BR>Const adLockOptimistic = 3<BR><BR><BR>&#039;Declare our variables<BR>Dim oConn<BR>Dim oRS<BR><BR>&#039;Open a connection<BR>Set oConn = Server.CreateObject("ADODB.Connection")<BR>oConn.O pen ConnStr<BR><BR>&#039;Create the Recordset object<BR>Set oRS = Server.CreateObject("ADODB.Recordset")<BR>oRS.Curs orLocation = adUseClient<BR><BR>&#039;Populate the Recordset object with a SQL query<BR>oRS.Open strSQL, oConn, adOpenStatic, adLockBatchOptimistic<BR><BR>&#039;Disconnect the Recordset<BR>Set oRS.ActiveConnection = Nothing<BR><BR>&#039;Return the Recordset<BR>Set GetRS = oRS<BR><BR><BR>&#039;Clean up...<BR>oConn.Close<BR>oRS.Close<BR>Set oConn = Nothing<BR>Set oRS = Nothing<BR>End Function<BR><BR>set RS = GetRS(strSQL)<BR><BR>If not (RS.eof or RS.bof) then<BR>aRecords = RS.GetRows()<BR>oRS.Close<BR>End if<BR><BR>What am I doing wrong?<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Disconnected Record Set example

    In:<BR>------<BR>If not (RS.eof or RS.bof) then<BR>aRecords = RS.GetRows()<BR>oRS.Close<BR>End if<BR>------<BR>you cannot, and even don&#039;t need, to close "oRS" as you&#039;ve already done it in function GetRS.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts