I see ProjectTracker, everytime DataPortal_XX is called, a connection is opened. I think program is slowly.
private void DataPortal_Fetch(Criteria criteria)
{
using (SqlConnection cn = new SqlConnection(Database.PTrackerConnection))
{
cn.Open();
using (SqlCommand cm = cn.CreateCommand())
{
cm.CommandType = CommandType.StoredProcedure;
cm.CommandText = "getResources";
using (SafeDataReader dr =
new SafeDataReader(cm.ExecuteReader()))
{
IsReadOnly = false;
while (dr.Read())
{
ResourceInfo info = new ResourceInfo(dr);
this.Add(info);
}
IsReadOnly = false;
}
}
}
}
Hi,
You will notice if you test this out that you only get the initial connection hit the first time you connect (and even that is minimal), any subsequent calls after that are almost instant due to connection pooling.
I haven't had any perfomance issues with the connection.
Regards
Craig
Hi,
CSLA is a form of disconnected data: the connection to the database should only be held open as short as possible while retrieving or storing data but not while the user works with the data or drinks a cup of coffee. This way ADO.NET can use connection pooling and can reuse closed connections.
Greetings,
Christian
Copyright (c) Marimer LLC