Whats my RecordSet doing?

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

  1. #1

    Default Whats my RecordSet doing?

    Hi All

    I'd just like to confirm something with you if you don't mind.

    Basically when my ASP page contains 3 or 4 queries, in my own little world I
    thought I was conserving resources by reusing the main ADODB objects of
    Connection, Command and Recordset rather than continually creating,
    dropping, creating, etc An example is as follows:

    Set oConn = Server.CreateObject("ADODB.Connection")
    oConn.Connectionstring = strDSN
    oConn.Open

    Set oCmd=Server.CreateObject("ADODB.Command")
    Set oCmd.ActiveConnection = oConn
    oCmd.CommandText = "PostOrder(" & myorderparams & ")"
    oCmd.CommandType = 4
    oCmd.Execute


    oCmd.CommandText = "GetOrderNo()"
    oCmd.CommandType = 4

    Set oRSv=Server.CreateObject("ADODB.recordset")
    oRSv.open oCmd

    IF NOT oRSv.EOF THEN
    strOrderNo = oRSv("ORDERNO")
    END IF

    oRSv.close


    oCmd.CommandText = "ShowReport()"
    oCmd.CommandType = 4

    oRSv.open oCmd

    IF NOT oRSv.EOF THEN
    strOrderNo = oRSv("ORDERNO")
    END IF

    oRSv.close


    Set oRSv=nothing
    Set oCmd=nothing
    oConn.close
    Set oConn=nothing

    Now the same 1 Command object seems to be reusable, but am I actually only
    using 1 Recordset object or is it that when I 'oRSv.close' and then
    'oRSv.open oCmd' I'm actually completely closing and recreating a oRSv
    Recordset each time?

    I'm not actually setting the oRSv to nothing until the end, but if I don't
    use the '.close' option then I can't reuse my oRSv recordset for another
    job.

    I just want to be resourceful as possible on this aspect and my decision was
    that if the above is in fact dropping and re-creating a recordset each time,
    I would create my Command and Recordset objects at the beginning of my page
    (in an include file), do the required jobs and then have a closing objects
    include file at the end of the page.

    Thanks

    Laphan




    Laphan Guest

  2. Similar Questions and Discussions

    1. Whats the problem with my SQL???
      I'm having problem with my SQL Statement, can anyone help me? Here's the error: Error Type: ADODB.Recordset (0x800A0E7D) The connection cannot be...
    2. Whats the best way ??
      I have just purchased Contribute to allow our marketing department to add content to our web site. Up until now I've had a local copy on my C drive...
    3. RecordSet.Move or RecordSet.AbsolutePosition??
      Hi, I'm trying to use either one of these methods to position the cursor in a specific position inside a recordset, but neither one seems to...
    4. whats the best way to?
      write one function (for navigation) and call it in multiple asp.net pages? - i would use an include file as i do in asp but i gather this isnt the...
    5. Whats Is Fast For Setting Recordset !
      Dear Friends Hope you all doing great. Few days ago I asked you all for a coment on using Access and ASP. I got many replies. In one of the...
  3. #2

    Default Re: Whats my RecordSet doing?

    Laphan wrote:
    > Hi All
    >
    > I'd just like to confirm something with you if you don't mind.
    >
    > Basically when my ASP page contains 3 or 4 queries, in my own little
    > world I thought I was conserving resources by reusing the main ADODB
    > objects of Connection, Command and Recordset rather than continually
    > creating, dropping, creating, etc
    What has made you doubt this?
    > Now the same 1 Command object seems to be reusable, but am I actually
    > only using 1 Recordset object or is it that when I 'oRSv.close' and
    > then 'oRSv.open oCmd' I'm actually completely closing and recreating
    > a oRSv Recordset each time?
    What difference does it make? Yes, you are closing and re-opening it with a
    different source.
    >
    > I'm not actually setting the oRSv to nothing until the end, but if I
    > don't use the '.close' option then I can't reuse my oRSv recordset
    > for another job.
    This is true.

    >
    > I just want to be resourceful as possible on this aspect and my
    > decision was that if the above is in fact dropping
    There's no dropping done when the recordset is closed. The recordet's
    properties and Fields collection are reset, but you still have a recordset
    object in memory.
    > and re-creating a
    > recordset each time,
    No, you are not recreating it when you use .Open. You are resetting its
    properties and Fields collection to the new values provided by the new data
    source.
    > I would create my Command and Recordset objects
    > at the beginning of my page (in an include file), do the required
    > jobs and then have a closing objects include file at the end of the
    > page.
    >
    As I said in my last reply, this is my preferred way of doing it. I only use
    multiple recordset variables when I need to have two recordsets opened
    simultaneously, which is rare.

    Time to move on. Stop obsessing about this.

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows Guest

  4. #3

    Default Re: Whats my RecordSet doing?

    Thanks for the therapy session Bob.

    Much appreciated.

    Rgds

    Robbie


    "Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
    news:OTTSVPtKEHA.1280@TK2MSFTNGP10.phx.gbl...
    Laphan wrote:
    > Hi All
    >
    > I'd just like to confirm something with you if you don't mind.
    >
    > Basically when my ASP page contains 3 or 4 queries, in my own little
    > world I thought I was conserving resources by reusing the main ADODB
    > objects of Connection, Command and Recordset rather than continually
    > creating, dropping, creating, etc
    What has made you doubt this?
    > Now the same 1 Command object seems to be reusable, but am I actually
    > only using 1 Recordset object or is it that when I 'oRSv.close' and
    > then 'oRSv.open oCmd' I'm actually completely closing and recreating
    > a oRSv Recordset each time?
    What difference does it make? Yes, you are closing and re-opening it with a
    different source.
    >
    > I'm not actually setting the oRSv to nothing until the end, but if I
    > don't use the '.close' option then I can't reuse my oRSv recordset
    > for another job.
    This is true.

    >
    > I just want to be resourceful as possible on this aspect and my
    > decision was that if the above is in fact dropping
    There's no dropping done when the recordset is closed. The recordet's
    properties and Fields collection are reset, but you still have a recordset
    object in memory.
    > and re-creating a
    > recordset each time,
    No, you are not recreating it when you use .Open. You are resetting its
    properties and Fields collection to the new values provided by the new data
    source.
    > I would create my Command and Recordset objects
    > at the beginning of my page (in an include file), do the required
    > jobs and then have a closing objects include file at the end of the
    > page.
    >
    As I said in my last reply, this is my preferred way of doing it. I only use
    multiple recordset variables when I need to have two recordsets opened
    simultaneously, which is rare.

    Time to move on. Stop obsessing about this.

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"



    Astra 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