Database connection sharing

Discussion in 'ASP .Net' started by Atif Jalal, Aug 8, 2003.

  1. Atif Jalal

    Atif Jalal Guest

    How can I share the sane databse connection between asp.net pages. I
    also use objects(middleware), so can I pass the same DB connection
    when I instantiate the object by calling its constructor?
     
    Atif Jalal, Aug 8, 2003
    #1
    1. Advertisements

  2. This connection sharing is done automatically. ADO.NET has built in
    connection pooling.
    Open your db connection just before you need it, and close it as soon as you
    are done with it.
    As long as you use the same exact connection string everywhere the sharing
    will be automatic - you will not actually open a new database connection
    each time despite what the syntax suggests. The connections will be
    recycled for you.
    Purposely keeping connections open and trying to pass them to other pages
    will result in inefficient, poorly performing code.

    --
    I hope this helps,
    Steve C. Orr, MCSD
    http://Steve.Orr.net


    "Atif Jalal" <> wrote in message
    news:...
    > How can I share the sane databse connection between asp.net pages. I
    > also use objects(middleware), so can I pass the same DB connection
    > when I instantiate the object by calling its constructor?
     
    Steve C. Orr, MCSD, Aug 8, 2003
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. et

    Sharing an access database

    et, Oct 16, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    5,119
  2. David Dvali

    Sharing DB connection

    David Dvali, Jul 13, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    506
    Kevin Spencer
    Jul 13, 2005
  3. Mythran
    Replies:
    5
    Views:
    5,281
    Mythran
    Oct 5, 2005
  4. janne

    DAOs and Connection sharing

    janne, Jul 30, 2004, in forum: Java
    Replies:
    2
    Views:
    663
    John Fereira
    Jul 31, 2004
  5. Replies:
    1
    Views:
    432
    Daniel Dittmar
    Feb 1, 2006
  6. Mike P2
    Replies:
    4
    Views:
    515
    Eliyahu Goldin
    Jun 3, 2007
  7. patrick boulay
    Replies:
    7
    Views:
    7,636
    PatrickBlais
    Apr 2, 2009
  8. Andrew DeFaria
    Replies:
    7
    Views:
    693
    Tad J McClellan
    Apr 2, 2008
Loading...