RAD Studio |  |

Controlling Timeouts
See Also
Collapse All

You can control the amount of time that can elapse before attempted commands and connections are considered failed and are aborted using the ConnectionTimeout and CommandTimeout properties.

ConnectionTimeout specifies the amount of time, in seconds, before an attempt to connect to the data store times out. If the connection does not successfully compile prior to expiration of the time specified in ConnectionTimeout, the connection attempt is canceled:

Copy Code

    with ADOConnection1 do begin
      ConnectionTimeout := 10 {seconds};
      Open;
    end;

Copy Code

      ADOConnection1->ConnectionTimeout = 10; // seconds
      ADOConnection1->Open();

CommandTimeout specifies the amount of time, in seconds, before an attempted command times out. If a command initiated by a call to the Execute method does not successfully complete prior to expiration of the time specified in CommandTimeout, the command is canceled and ADO generates an exception:

Copy Code

    with ADOConnection1 do begin
      CommandTimeout := 10 {seconds};
      Execute("DROP TABLE Employee1997", cmdText, []);
    end;

Copy Code

      ADOConnection1->ConnectionTimeout = 10;
      ADOConnection1->Execute("DROP TABLE Employee1997", cmdText, TExecuteOptions());

See Also

Specifying Whether the Connection Automatically Initiates Transactions

Indicating the Types of Operations the Connection Supports

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!