painlessprod
asked on
SQL Connection Timeout
I am setting the timeout in a connection string to be 420 seconds but for some reason it still times out at 30, I've run the query in analyzer and it's all good, in the example below i set the timeout to 0 which should be infinite
Here's the code
public DataAccess(string psUser, string psPassword, string psServer, string psDB)
{
mstrConnection = "Network Library=DBMSSOCN;Data Source=" + psServer + ";Initial Catalog=" + psDB + ";User ID=" + psUser + ";Password=" + psPassword + ";Connection Timeout = 0";
}
public DataTable ExportShorts()
{
System.Diagnostics.Debug.W riteLine(m strConnect ion);
SqlConnection conn = new SqlConnection(mstrConnecti on);
System.Diagnostics.Debug.W riteLine(c onn.Connec tionTimeou t);
DataSet ds = new DataSet();
DataTable dt = new DataTable();
ds=SqlHelper.ExecuteDatase t(conn, CommandType.StoredProcedur e, "ShortPositionAges");
dt=ds.Tables[0];
return dt;
}
Thanks
Here's the code
public DataAccess(string psUser, string psPassword, string psServer, string psDB)
{
mstrConnection = "Network Library=DBMSSOCN;Data Source=" + psServer + ";Initial Catalog=" + psDB + ";User ID=" + psUser + ";Password=" + psPassword + ";Connection Timeout = 0";
}
public DataTable ExportShorts()
{
System.Diagnostics.Debug.W
SqlConnection conn = new SqlConnection(mstrConnecti
System.Diagnostics.Debug.W
DataSet ds = new DataSet();
DataTable dt = new DataTable();
ds=SqlHelper.ExecuteDatase
dt=ds.Tables[0];
return dt;
}
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Well that worked.
Upon doing further research I found that SQLHelper doesn't allow a command timeout, it has a connection timeout but not a command timeout. So SQLHelper is useless for large stored procedures. Otherwise SQLHelper is a very useful tool.
Thanks gillit
Upon doing further research I found that SQLHelper doesn't allow a command timeout, it has a connection timeout but not a command timeout. So SQLHelper is useless for large stored procedures. Otherwise SQLHelper is a very useful tool.
Thanks gillit
ASKER