Forum Discussion

tcsdungeon's avatar
tcsdungeon
New Contributor
7 years ago

TestComplete adjust query timeout

Is it possible to adjust the query timeout inside of TestComplete?  I am currently running a query that when run in SQL Server Management Studio (SSMS), it takes 37 seconds to generate the results, but when I run the same query inside of TestComplete, I receive the following error.  Unable to display the table data.  The following error occurred:  Query timeout expired

 

 

10 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    What code are you using for executing the SQL query?  It someone depends upon that.  If you're using the various ADO objects available in TestComplete, there is a way of setting the query timeout.

     

    Basically, within the ADO schema, for everything there is a command object or you create one using ADO.CreateADOCommand.  That command object has a property called "CommandTimeout".  Set that to a numeric value, in seconds, to set your timeout value for your query.

    • tcsdungeon's avatar
      tcsdungeon
      New Contributor

      I am using TestComplete to execute my query.  I am in the process of setting up a data driven loop, so in Variables tab, I have set the type to DB Table, and the Default Value information is as follows:  Specify the data source type (set to Database query), I have selected the server name, and selected the specific database, tested the connection, and it connects. Specify Query (I have put in the query and click the View Results Button.)   It is when I click the View Results Button, that I receive the query time expired error.  I haven't been able to figure out where to change the query time length.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        With a more complicated query, is there a reason why you're not using DB Query as the option instead of DB table?

         

        As it is, I'm not sure there is a way to change that timeout value in TestComplete.  The default for ADO objects is 30 seconds so that is probably what is being used internally.

         

        Your alternative is to build your data driven loop in script code and pass the result set to your keyword test for execution in some fashion.  That way you can create your own query objects and such using ADO and over-ride the default command timeout.

         

        As a side note:  37 seconds to execute a Select query against a database is an AWFUL long time.  Either you have a whole LOT of data to retrieve or your query is not taking advantage of indexes and is doing table scans.  I'd actually take a look at refining your query to see if you can speed it up.

  • karkadil's avatar
    karkadil
    Valued Contributor

    Just pass additional parameter in your connection string:

    Connect Timeout=600
    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      karkadil wrote:

      Just pass additional parameter in your connection string:

      Connect Timeout=600

      Isn't connection time out handled differently than command or query timeout?  The connection may be open just fine but there may be a maximum query limit.  I know that was the case with a stored procedure that I needed to run during my tests.  I needed to specifically boost the command timeout.

      • karkadil's avatar
        karkadil
        Valued Contributor

        Oooops, my bad.

        Robert is right, please ignore my advise.