Connection Pooling and the data access application block

Discussion in 'ASP .Net' started by Edward W., Dec 15, 2004.

  1. Edward W.

    Edward W. Guest

    I was looking at the data access application block version 2 and considering
    what I had read about connection pooling in that to use connection pooling
    successfully, you should close your sqlconnections as quickly as possible.
    The DAAB doesn't seem to close or dispose of connections. Are people using
    the DAAB on web applications or maybe have people added to the DAAB to
    close/dispose connections?
     
    Edward W., Dec 15, 2004
    #1
    1. Advertising

  2. Edward W.

    Chris Hyde Guest

    Edward W. wrote:
    > I was looking at the data access application block version 2 and considering
    > what I had read about connection pooling in that to use connection pooling
    > successfully, you should close your sqlconnections as quickly as possible.
    > The DAAB doesn't seem to close or dispose of connections. Are people using
    > the DAAB on web applications or maybe have people added to the DAAB to
    > close/dispose connections?
    >
    >

    The DAAB DOES handle connections properly, when its creates the
    connection itself (using the methods that take a connection string as a
    parameter), and it also allows you to pass in your own connection
    object. If you pass in your own connection object, you are required to
    handle its opening/closing yourself.

    HTH...
    Chris
     
    Chris Hyde, Dec 15, 2004
    #2
    1. Advertising

  3. DAAB is a really great framework... the only issue that I had with it
    was the lack of a good way to handle transactions, although you can
    manually do it with the ExecuteScalar function.

    Yes, it does close connections properly.

    Lowell



    Chris Hyde wrote:
    > Edward W. wrote:
    >
    >> I was looking at the data access application block version 2 and
    >> considering what I had read about connection pooling in that to use
    >> connection pooling successfully, you should close your sqlconnections
    >> as quickly as possible. The DAAB doesn't seem to close or dispose of
    >> connections. Are people using the DAAB on web applications or maybe
    >> have people added to the DAAB to close/dispose connections?
    >>

    > The DAAB DOES handle connections properly, when its creates the
    > connection itself (using the methods that take a connection string as a
    > parameter), and it also allows you to pass in your own connection
    > object. If you pass in your own connection object, you are required to
    > handle its opening/closing yourself.
    >
    > HTH...
    > Chris
     
    Lowell Heddings, Dec 15, 2004
    #3
  4. Edward W.

    WJ Guest

    DAAB handles everything for you efficiently. Using DAAB also reduces bugs. I
    always close my own connection, however, I check the state of connection
    before closing/opening it.

    John

    "Edward W." <> wrote in message
    news:...
    >I was looking at the data access application block version 2 and
    >considering what I had read about connection pooling in that to use
    >connection pooling successfully, you should close your sqlconnections as
    >quickly as possible. The DAAB doesn't seem to close or dispose of
    >connections. Are people using the DAAB on web applications or maybe have
    >people added to the DAAB to close/dispose connections?
    >
     
    WJ, Dec 15, 2004
    #4
  5. I've been using DAAB since v1 and am currently using v2 and find it to be
    very solid. The DAAB allows consumer to pass in a connection or transaction
    object to method overloads and it's up to the consumer to close connection
    (cleanup in the finally portion of try...catch block to ensure connections
    are being disposed of properly).

    Consuming code also has access to overloads that take a connection string -
    in this instance the DAAB handles opening and closing the connection for you
    (in an efficient manner). Also keep in mind that connections are pooled per
    unique connection string.

    "Edward W." wrote:

    > I was looking at the data access application block version 2 and considering
    > what I had read about connection pooling in that to use connection pooling
    > successfully, you should close your sqlconnections as quickly as possible.
    > The DAAB doesn't seem to close or dispose of connections. Are people using
    > the DAAB on web applications or maybe have people added to the DAAB to
    > close/dispose connections?
    >
    >
    >
     
    =?Utf-8?B?SlAuU2tsZW5rYQ==?=, Dec 15, 2004
    #5
  6. DAAB is using "The using statement" which automatically calls Dispose on the
    object being "used" when leaving the scope of the using statement.
    For example:
    //C#

    string connString = "Data Source=localhost;Integrated
    Security=SSPI;Initial Catalog=Northwind;";
    using (SqlConnection conn = new SqlConnection(connString))
    {

    SqlCommand cmd = conn.CreateCommand();
    cmd.CommandText = "SELECT CustomerId, CompanyName FROM Customers";
    conn.Open();
    using (SqlDataReader dr = cmd.ExecuteReader())
    {
    while (dr.Read())
    Console.WriteLine("{0}\t{1}", dr.GetString(0),
    dr.GetString(1));
    }
    }


    "Edward W." wrote:

    > I was looking at the data access application block version 2 and considering
    > what I had read about connection pooling in that to use connection pooling
    > successfully, you should close your sqlconnections as quickly as possible.
    > The DAAB doesn't seem to close or dispose of connections. Are people using
    > the DAAB on web applications or maybe have people added to the DAAB to
    > close/dispose connections?
    >
    >
    >
     
    =?Utf-8?B?SEFSSSBQUkFTRCBCQVJV?=, Dec 15, 2004
    #6
    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. William \(Bill\) Vaughn

    Re: SqlConnection and connection pooling

    William \(Bill\) Vaughn, Nov 14, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    493
    William \(Bill\) Vaughn
    Nov 14, 2003
  2. Showjumper
    Replies:
    1
    Views:
    706
    Showjumper
    Mar 19, 2005
  3. Rob Nicholson

    ADO.NET, connection pooling and ASP.NET

    Rob Nicholson, Aug 31, 2005, in forum: ASP .Net
    Replies:
    18
    Views:
    4,492
    Rob Nicholson
    Sep 17, 2005
  4. morrell
    Replies:
    1
    Views:
    967
    roy axenov
    Oct 10, 2006
  5. Sanjeev
    Replies:
    0
    Views:
    757
    Sanjeev
    May 27, 2008
Loading...

Share This Page