I'm using the Data Access Application Block (SQLHelper) to execute SQL against a database. I have one query which takes longer than the default command timeout of 30 seconds. I want to up the timeout, but I don't see any way to do so without cracking open the Application Block. Is there any way to change the CommandTimeout without modifying the SQLHelper class?
Setting CommandTimeout in Microsoft's Data Access Application Block (SQLHelper)
4.7k Views Asked by Mashmagar At
3
There are 3 best solutions below
0

If you still are using the old version of DAAB, there are numerous overloads of FillDataset that have command timeout as a parameter.
public static void FillDataset(string connectionString, CommandType commandType, int commandTimeout, string commandText, DataSet dataSet, string[] tableNames)
public static void FillDataset(string connectionString, CommandType commandType, int commandTimeout, string commandText, DataSet dataSet, string[] tableNames, params SqlParameter[] commandParameters)
public static void FillDataset(string connectionString, string spName, int commandTimeout, DataSet dataSet, string[] tableNames, params object[] parameterValues)
public static void FillDataset(SqlConnection connection, CommandType commandType, int commandTimeout, string commandText, DataSet dataSet, string[] tableNames)
public static void FillDataset(SqlConnection connection, CommandType commandType, int commandTimeout, string commandText, DataSet dataSet, string[] tableNames, params SqlParameter[] commandParameters)
public static void FillDataset(SqlConnection connection, string spName, int commandTimeout, DataSet dataSet, string[] tableNames, params object[] parameterValues)
public static void FillDataset(SqlTransaction transaction, CommandType commandType, int commandTimeout, string commandText, DataSet dataSet, string[] tableNames)
public static void FillDataset(SqlTransaction transaction, CommandType commandType, int commandTimeout, string commandText, DataSet dataSet, string[] tableNames, params SqlParameter[] commandParameters)
public static void FillDataset(SqlTransaction transaction, string spName, int commandTimeout, DataSet dataSet, string[] tableNames, params object[] parameterValues)
SQLHelper is replaced by 'Database' in newer versions of DAAB . You can then use DbCommand.SetCommandTimeOut - see here