Mashmagar
Mashmagar

Reputation: 2664

Setting CommandTimeout in Microsoft's Data Access Application Block (SQLHelper)

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?

Upvotes: 2

Views: 4828

Answers (3)

Bart Sipes
Bart Sipes

Reputation: 931

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)

Upvotes: 1

StuartLC
StuartLC

Reputation: 107267

SQLHelper is replaced by 'Database' in newer versions of DAAB . You can then use DbCommand.SetCommandTimeOut - see here

Upvotes: 3

Manjesh
Manjesh

Reputation: 29

Well I could not find answer either, so what I did is, I copied the SQLHelper.cd from DAAB in to my project and started using that. ( Its just on file so it was easy )

Now I can change the connection timeout in SQLHelper.cs.

I have no clue on why this is not configurable in DAAB

Manjesh

Upvotes: 2

Related Questions