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. Advertising

  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. Advertising

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. David Dvali

    Sharing DB connection

    David Dvali, Jul 13, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    416
    Kevin Spencer
    Jul 13, 2005
  2. Mythran
    Replies:
    5
    Views:
    4,968
    Mythran
    Oct 5, 2005
  3. Replies:
    1
    Views:
    328
    Daniel Dittmar
    Feb 1, 2006
  4. Mike P2
    Replies:
    4
    Views:
    364
    Eliyahu Goldin
    Jun 3, 2007
  5. Andrew DeFaria
    Replies:
    7
    Views:
    330
    Tad J McClellan
    Apr 2, 2008
Loading...

Share This Page