Connection Pooling and the data access application block

E

Edward W.

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?
 
C

Chris Hyde

Edward said:
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
 
L

Lowell Heddings

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
 
W

WJ

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
 
G

Guest

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

Guest

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));
}
}
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top