RAD Studio
ContentsIndex
PreviousUpNext
Controlling Timeouts

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:

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

 

  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:

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

 

  ADOConnection1->ConnectionTimeout = 10;
  ADOConnection1->Execute("DROP TABLE Employee1997", cmdText, TExecuteOptions());
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!