Web service with open db connection

Discussion in 'ASP .Net Web Services' started by Mantorok, Jun 11, 2007.

  1. Mantorok

    Mantorok Guest

    Hi all

    ASP.Net v2.0.

    I have a web service that holds an "open" OleDb connection in one of its
    session variables, when the session times out does this connection close, or
    does it only close when another request comes through after the timeout?

    Hope that makes sense.

    Thanks
    Kev
     
    Mantorok, Jun 11, 2007
    #1
    1. Advertising

  2. Hi Kev,

    From your description, you're using OleDb components to access database in
    ASP.NET 2.0 application. and you're wondering how to correctly open and
    dispose the connection objects in the application's lifecycle, correct?

    Based on my experience, in .net framework application which use ADO.NET
    component to access database, you do not need to manually cache the
    connection object since by default the .NET managed provider or underlying
    OLEdb provider will use connecction pool to manage all the connections.
    That means you do not need to manually open a connection object and keep it
    open (stored in Session or other global storage). The recommended pattern
    is open the connecction and close it as soon as you finish using it. The
    connection pool will help you cache and pooling the underlying physical
    connection to database and will improve performance when you frequently
    open ADO.NET connection to database.

    #ADO.Net connection pooling
    http://weblogs.asp.net/sjoseph/archive/2005/03/23/395601.aspx

    #Connection Pooling and Connection Management
    http://www.dbazine.com/sql/sql-articles/charran2

    #Get IT Done: How connection pooling can boost ADO.NET performance
    http://articles.techrepublic.com.com/5100-6329_11-5034285.html

    BTW, for webservice, session state is an ASP.NET specific feature that does
    not conform to webservice standard, if you do want to cache some global
    data, you can also consider using a static class member (such as a static
    hashtable variable in a public class).

    If you have any further questions or anything else wonder, please feel free
    to post here.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    ==================================================

    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    ications.



    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscriptions/support/default.aspx.

    ==================================================


    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Jun 12, 2007
    #2
    1. Advertising

  3. Mantorok

    Mantorok Guest

    Thank you very much, that answers my query perfectly.

    Kev

    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi Kev,
    >
    > From your description, you're using OleDb components to access database in
    > ASP.NET 2.0 application. and you're wondering how to correctly open and
    > dispose the connection objects in the application's lifecycle, correct?
    >
    > Based on my experience, in .net framework application which use ADO.NET
    > component to access database, you do not need to manually cache the
    > connection object since by default the .NET managed provider or underlying
    > OLEdb provider will use connecction pool to manage all the connections.
    > That means you do not need to manually open a connection object and keep
    > it
    > open (stored in Session or other global storage). The recommended
    > pattern
    > is open the connecction and close it as soon as you finish using it. The
    > connection pool will help you cache and pooling the underlying physical
    > connection to database and will improve performance when you frequently
    > open ADO.NET connection to database.
    >
    > #ADO.Net connection pooling
    > http://weblogs.asp.net/sjoseph/archive/2005/03/23/395601.aspx
    >
    > #Connection Pooling and Connection Management
    > http://www.dbazine.com/sql/sql-articles/charran2
    >
    > #Get IT Done: How connection pooling can boost ADO.NET performance
    > http://articles.techrepublic.com.com/5100-6329_11-5034285.html
    >
    > BTW, for webservice, session state is an ASP.NET specific feature that
    > does
    > not conform to webservice standard, if you do want to cache some global
    > data, you can also consider using a static class member (such as a static
    > hashtable variable in a public class).
    >
    > If you have any further questions or anything else wonder, please feel
    > free
    > to post here.
    >
    > Sincerely,
    >
    > Steven Cheng
    >
    > Microsoft MSDN Online Support Lead
    >
    >
    >
    > ==================================================
    >
    > Get notification to my posts through email? Please refer to
    > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
    > ications.
    >
    >
    >
    > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    > where an initial response from the community or a Microsoft Support
    > Engineer within 1 business day is acceptable. Please note that each follow
    > up response may take approximately 2 business days as the support
    > professional working with you may need further investigation to reach the
    > most efficient resolution. The offering is not appropriate for situations
    > that require urgent, real-time or phone-based interactions or complex
    > project analysis and dump analysis issues. Issues of this nature are best
    > handled working with a dedicated Microsoft Support Engineer by contacting
    > Microsoft Customer Support Services (CSS) at
    > http://msdn.microsoft.com/subscriptions/support/default.aspx.
    >
    > ==================================================
    >
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
    >
    >
    >
    >
    >
    >
     
    Mantorok, Jun 12, 2007
    #3
  4. You're welcome:)

    Have a good day!

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.
     
    Steven Cheng[MSFT], Jun 13, 2007
    #4
    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. THY
    Replies:
    4
    Views:
    517
    Gönen EREN
    Aug 22, 2003
  2. hocho888
    Replies:
    1
    Views:
    650
  3. Michael Averstegge
    Replies:
    0
    Views:
    4,246
    Michael Averstegge
    Jan 10, 2006
  4. Scott Baierl
    Replies:
    1
    Views:
    283
    Scott Baierl
    Jul 29, 2006
  5. Leo Violette
    Replies:
    0
    Views:
    1,057
    Leo Violette
    Apr 17, 2009
Loading...

Share This Page