Search code examples
sqlasp.netresponse

command timeout through SqlHelper in asp.net 2.0


I have an application that works with asp.net 2.0, I want to increase command timeout but it is using sqlHelper class;

dsData = SqlHelper.ExecuteDataset(connectionstring, System.Data.CommandType.StoredProcedure, spName, m_SqlParam)

I can't find any example on this, or should I change SqlHelper code?


Solution

  • You can use the SqlCommand.CommandTimeout property like below

    SqlCommand command = new SqlCommand(queryString, connection);    
    command.CommandTimeout = 20;
    

    Your SqlHelper looks like a custom wrapper (or) a repository class for the SqlCommand. In such case, you can either change your code base in your SqlHelper class (OR) have your ExecuteDataset() method accept another argument for timeout