ADODB Connection Question

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

  1. #1

    Default ADODB Connection Question

    Hi All

    Just IYHO, which is better:

    METHOD 1
    =========
    Creating the ADODB connection obejct at the beginning of an ASP page in an
    include file.

    Functions containing the requirement to create any ADODB commands or
    recorset ojects to do a query and then close/drop the same objects in an
    include file.

    Drop/close the ADODB connection obejct at the end of an ASP page in an
    include file.

    METHOD 2
    =========
    Encapsulate the ADODB connection within each of the functions so that when
    they are executed the connection, retrieval and drop is basically all in
    about 3 lines of code.

    As far as I can see Method 1 has the bonus of only creating 1 connection
    object and then allowing the commands and recordsets to feed off this, but
    then again the connection is open for the time it takes the full page to be
    generated.

    As far as I can see for Method 2 it does keep the connection open to a
    minimum, but if I have 3 or 4 queries that need to be run then it means 3 or
    4 connections have to be created as well as the commands and recordsets.

    I favour Method 1, but what do you think? Is there a Method 3??

    Thanks

    Robbie


    Astra Guest

  2. Similar Questions and Discussions

    1. .NET returning ADODB.Connection to ASP
      Could someone tell me if I were to return a ADODB.Connection from a .NET dll to ASP, should I be able to use that connection? My .net dll...
    2. ADODB.Connection
      > Is there an advantage of one of these over the other, other than not having No. However, the advantage isn't just about being oblivious to the...
    3. ADODB.Connection error '800a0046'
      I am receiving the following error: ADODB.Connection error '800a0046' Permission Denied Here is my connection string on my web page: <% Dim...
    4. ADODB Connection
      Could anybody tell me please what the "1,2" refers to in the last line of this code and where I can get a list of the parts to this '.open'...
    5. The specified module could not be found. (ADODB.Connection)
      Hi I am getting the follwoing error message Server object error 'ASP 0177 : 8007007e' Server.CreateObject Failed /BI...
  3. #2

    Default Re: ADODB Connection Question

    I usually use the first method, with the modification that I do not open the
    connection until just before the first time I need it. IOW, instantiate the
    connection and set its connection string in the include file. Then, wait
    until the first time you need it to open it. Don't open it then do a lot of
    non-database-related activity before using it.

    I would only consider the second method if I was doing something for
    Amazon.com

    Bob Barrows

    Astra wrote:
    > Hi All
    >
    > Just IYHO, which is better:
    >
    > METHOD 1
    > =========
    > Creating the ADODB connection obejct at the beginning of an ASP page
    > in an include file.
    >
    > Functions containing the requirement to create any ADODB commands or
    > recorset ojects to do a query and then close/drop the same objects in
    > an include file.
    >
    > Drop/close the ADODB connection obejct at the end of an ASP page in an
    > include file.
    >
    > METHOD 2
    > =========
    > Encapsulate the ADODB connection within each of the functions so that
    > when they are executed the connection, retrieval and drop is
    > basically all in about 3 lines of code.
    >
    > As far as I can see Method 1 has the bonus of only creating 1
    > connection object and then allowing the commands and recordsets to
    > feed off this, but then again the connection is open for the time it
    > takes the full page to be generated.
    >
    > As far as I can see for Method 2 it does keep the connection open to a
    > minimum, but if I have 3 or 4 queries that need to be run then it
    > means 3 or 4 connections have to be created as well as the commands
    > and recordsets.
    >
    > I favour Method 1, but what do you think? Is there a Method 3??
    >
    > Thanks
    >
    > Robbie
    --
    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: ADODB Connection Question


    The first is the best imo, because that way you will only be opening 1
    connection per page. I have the habbit of passing the ADO connections as a
    parameter to objects or functions that need one, instead of having those
    create their own every time.

    I'd avoid always opening the connection in the include file though, because
    in some cases you might not need it at all, in which case setting up a DB
    connection is a waste of resources (although with ADO connection pooling
    this is probably very minimal).

    "Astra" <info@NoEmail.com> wrote in message
    news:e$WwVPFKEHA.1388@TK2MSFTNGP09.phx.gbl...
    > Hi All
    >
    > Just IYHO, which is better:
    >
    > METHOD 1
    > =========
    > Creating the ADODB connection obejct at the beginning of an ASP page in an
    > include file.
    >
    > Functions containing the requirement to create any ADODB commands or
    > recorset ojects to do a query and then close/drop the same objects in an
    > include file.
    >
    > Drop/close the ADODB connection obejct at the end of an ASP page in an
    > include file.
    >
    > METHOD 2
    > =========
    > Encapsulate the ADODB connection within each of the functions so that when
    > they are executed the connection, retrieval and drop is basically all in
    > about 3 lines of code.
    >
    > As far as I can see Method 1 has the bonus of only creating 1 connection
    > object and then allowing the commands and recordsets to feed off this, but
    > then again the connection is open for the time it takes the full page to
    be
    > generated.
    >
    > As far as I can see for Method 2 it does keep the connection open to a
    > minimum, but if I have 3 or 4 queries that need to be run then it means 3
    or
    > 4 connections have to be created as well as the commands and recordsets.
    >
    > I favour Method 1, but what do you think? Is there a Method 3??
    >
    > Thanks
    >
    > Robbie
    >
    >

    J. Baute Guest

  5. #4

    Default Re: ADODB Connection Question

    Thanks Guys

    J. Baute <WUPYRDEDAWJD@spammotel.com> wrote in message
    news:4088ccb7$0$10939$a0ced6e1@news.skynet.be...

    The first is the best imo, because that way you will only be opening 1
    connection per page. I have the habbit of passing the ADO connections as a
    parameter to objects or functions that need one, instead of having those
    create their own every time.

    I'd avoid always opening the connection in the include file though, because
    in some cases you might not need it at all, in which case setting up a DB
    connection is a waste of resources (although with ADO connection pooling
    this is probably very minimal).

    "Astra" <info@NoEmail.com> wrote in message
    news:e$WwVPFKEHA.1388@TK2MSFTNGP09.phx.gbl...
    > Hi All
    >
    > Just IYHO, which is better:
    >
    > METHOD 1
    > =========
    > Creating the ADODB connection obejct at the beginning of an ASP page in an
    > include file.
    >
    > Functions containing the requirement to create any ADODB commands or
    > recorset ojects to do a query and then close/drop the same objects in an
    > include file.
    >
    > Drop/close the ADODB connection obejct at the end of an ASP page in an
    > include file.
    >
    > METHOD 2
    > =========
    > Encapsulate the ADODB connection within each of the functions so that when
    > they are executed the connection, retrieval and drop is basically all in
    > about 3 lines of code.
    >
    > As far as I can see Method 1 has the bonus of only creating 1 connection
    > object and then allowing the commands and recordsets to feed off this, but
    > then again the connection is open for the time it takes the full page to
    be
    > generated.
    >
    > As far as I can see for Method 2 it does keep the connection open to a
    > minimum, but if I have 3 or 4 queries that need to be run then it means 3
    or
    > 4 connections have to be created as well as the commands and recordsets.
    >
    > I favour Method 1, but what do you think? Is there a Method 3??
    >
    > Thanks
    >
    > Robbie
    >
    >



    Laphan 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