Database connection sharing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Atif Jalal

    #1

    Database connection sharing

    How can I share the sane databse connection between asp.net pages. I
    also use objects(middlew are), so can I pass the same DB connection
    when I instantiate the object by calling its constructor?
  • Steve C. Orr, MCSD

    #2
    Re: Database connection sharing

    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



    "Atif Jalal" <matif@hotmail. com> wrote in message
    news:b7af12d4.0 308081253.34038 0d2@posting.goo gle.com...[color=blue]
    > How can I share the sane databse connection between asp.net pages. I
    > also use objects(middlew are), so can I pass the same DB connection
    > when I instantiate the object by calling its constructor?[/color]


    Comment

    Working...