Can I re-use a recordset object?

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default Can I re-use a recordset object?

    I read the following somewhere:

    'ADO lets you reuse a recordset as long as you close it first'

    So, presumeably I can do this:

    SQL1 = "...."
    SQL2 = "...."
    set rs = new adodb.recordset
    rs.open SQL1, conn, ....
    ' do something with the RS recordset here
    rs.close

    rs.open SQL2, conn, ....
    ' do something with the RS recordset here
    rs.close

    set rs = nothing
    set conn = nothing

    Is it safe to do this?

    TIA ... Terry
    Terry Guest

  2. Similar Questions and Discussions

    1. adodb.recordset object and the IIS session object
      I was looking through the registry of a Windows 2000 Adv. Server I just built and noticed that the adodb.recordset object had been set to "both"...
    2. response.redirect and recordset/connection object?
      I have the following code. Should I close and release the database objects before run response.redirect("some url")? or will the response.redirect...
    3. Command Object and RecordSet ASP
      I am very knew to asp and Im having problems returning the results from my stored procedure in the browser. The asp code and the html form code is...
    4. Vb6 object returning ADO Recordset - Error in .NET
      Hi, My C#, ASP.NET application uses com-interop to call a vb6 method which returns a ADO 2.6 recordset. I can successfully call the COM...
    5. Seeing If Recordset Object Exists !
      The property statement below will aim to identify whether a recordset object (rs) exists, and is not eof; and set its value the the recordset data....
  3. #2

    Default Re: Can I re-use a recordset object?

    "Terry" <saintkilda@shaw.ca> wrote in message
    news:jr0e10t2b5p9mtq3ftq78b9p3fshepsjs4@4ax.com...
    > I read the following somewhere:
    >
    > 'ADO lets you reuse a recordset as long as you close it first'
    >
    > So, presumeably I can do this:
    >
    > SQL1 = "...."
    > SQL2 = "...."
    > set rs = new adodb.recordset
    > rs.open SQL1, conn, ....
    > ' do something with the RS recordset here
    > rs.close
    >
    > rs.open SQL2, conn, ....
    > ' do something with the RS recordset here
    > rs.close
    >
    > set rs = nothing
    > set conn = nothing
    >
    > Is it safe to do this?
    >
    > TIA ... Terry
    Yes


    Chris Hohmann Guest

  4. #3

    Default Re: Can I re-use a recordset object?

    Ok ... thanks ... the reason I ask is that I was getting the following
    error, sporadically:
    'ADODB.Field error '800a0bcd' Either BOF or EOF is true...
    etc.'

    I found the Microsoft article 230101 which explains it, but the fix
    doesn't apply to me, since I am already at Win2000 with MDAC2.7. But
    it was totally intermittent, usually working the first time, and then
    randomly after that. I know the query I submitted was good, and
    returned data, so the error was misleading. And there was one query
    in the vicinity of the code below (where i re-used the recordset), so
    thought maybe that might be the reason.

    I was able to get it to work consistently by simply moving code that
    was in an include file, into the base asp page.... no other changes..
    weird.

    Thanks again.... Terry


    On Tue, 27 Jan 2004 18:15:59 -0800, "Chris Hohmann"
    <nospam@thankyou.com> wrote:
    >"Terry" <saintkilda@shaw.ca> wrote in message
    >news:jr0e10t2b5p9mtq3ftq78b9p3fshepsjs4@4ax.com.. .
    >> I read the following somewhere:
    >>
    >> 'ADO lets you reuse a recordset as long as you close it first'
    >>
    >> So, presumeably I can do this:
    >>
    >> SQL1 = "...."
    >> SQL2 = "...."
    >> set rs = new adodb.recordset
    >> rs.open SQL1, conn, ....
    >> ' do something with the RS recordset here
    >> rs.close
    >>
    >> rs.open SQL2, conn, ....
    >> ' do something with the RS recordset here
    >> rs.close
    >>
    >> set rs = nothing
    >> set conn = nothing
    >>
    >> Is it safe to do this?
    >>
    >> TIA ... Terry
    >
    >Yes
    >
    Terry Guest

  5. #4

    Default Re: Can I re-use a recordset object?

    While you can do it, you may find it easier for others (and yourself) to
    follow your code and know what each recordset is for if you don't. I
    personally generally would not do this, unless it were just a "rsMisc" for
    grabbing random pieces of data here and there or something, I suppose.

    Ray at home

    "Terry" <saintkilda@shaw.ca> wrote in message
    news:jr0e10t2b5p9mtq3ftq78b9p3fshepsjs4@4ax.com...
    > I read the following somewhere:
    >
    > 'ADO lets you reuse a recordset as long as you close it first'
    >
    > So, presumeably I can do this:
    >
    > SQL1 = "...."
    > SQL2 = "...."
    > set rs = new adodb.recordset
    > rs.open SQL1, conn, ....
    > ' do something with the RS recordset here
    > rs.close
    >
    > rs.open SQL2, conn, ....
    > ' do something with the RS recordset here
    > rs.close
    >
    > set rs = nothing
    > set conn = nothing
    >
    > Is it safe to do this?
    >
    > TIA ... Terry

    Ray at Guest

  6. #5

    Default Re: Can I re-use a recordset object?

    Ray,

    Thanks... appreciate the feedback. And yes, that is basically what
    I'm using it for. A few miscellaneous bits, within the same bit of
    code, so thought I could save creating a new object.

    Terry


    On Wed, 28 Jan 2004 00:27:38 -0500, "Ray at <%=sLocation%>"
    <myFirstNameATlane34dotKOMM> wrote:
    >While you can do it, you may find it easier for others (and yourself) to
    >follow your code and know what each recordset is for if you don't. I
    >personally generally would not do this, unless it were just a "rsMisc" for
    >grabbing random pieces of data here and there or something, I suppose.
    >
    >Ray at home
    >
    >"Terry" <saintkilda@shaw.ca> wrote in message
    >news:jr0e10t2b5p9mtq3ftq78b9p3fshepsjs4@4ax.com.. .
    >> I read the following somewhere:
    >>
    >> 'ADO lets you reuse a recordset as long as you close it first'
    >>
    >> So, presumeably I can do this:
    >>
    >> SQL1 = "...."
    >> SQL2 = "...."
    >> set rs = new adodb.recordset
    >> rs.open SQL1, conn, ....
    >> ' do something with the RS recordset here
    >> rs.close
    >>
    >> rs.open SQL2, conn, ....
    >> ' do something with the RS recordset here
    >> rs.close
    >>
    >> set rs = nothing
    >> set conn = nothing
    >>
    >> Is it safe to do this?
    >>
    >> TIA ... Terry
    >
    Terry Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139