This wasn't happening before, so I'm assuming something I did is causing this, yet I can't see what it could be.
I have linq2sql set up against a sql server 2005 database. I'm only using stored procedures.
Most of my procedures are working fine, but this one particular update proc sometimes get's fired a few hundred times in a row (cloning the details of a header record).
This is causing timeouts, and running a script to see open connections shows my app connections all sleeping and taking up space.
Any thoughts, advice?
My datacontext is setup as a static variable in a service class:
private static WarehouseSystemDataContext dc
{
get
{
// It is being passed a closed SqlConnection object
WarehouseSystemDataContext _dc =
new WarehouseSystemDataContext(Constants.getWarehouseSystemConn());
_dc.ObjectTrackingEnabled = false;
_dc.CommandTimeout = 600;
return _dc;
}
}
You are creating a new connection each time the datacontext is referenced
private static WarehouseSystemDataContext _dc
private static WarehouseSystemDataContext dc
{
get
{
if(_dc == null)
{
// It is being passed a closed SqlConnection object
_dc = new WarehouseSystemDataContext(Constants.getWarehouseSystemConn());
_dc.ObjectTrackingEnabled = false;
_dc.CommandTimeout = 600;
}
return _dc;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.