SDAC

TCustomMSDataSet.CommandTimeout Property

Used to specify the wait time before terminating the attempt to execute a command and generating an error.

Class

TCustomMSDataSet

Syntax

property CommandTimeout: integer default 0;

Remarks

The time in seconds to wait for the command to execute.

The default value is 0. The 0 value indicates no limit (an attempt to execute a command will wait indefinitely).

If a command is successfully executed prior to the expiration of the seconds specified, CommandTimeout has no effect. Otherwise, the 'Query timeout expired' error is generated by SQL Server. This error has the DB_E_ABORTLIMITREACHED OLEDB error code.

For more information about OLEDB Errors, refer to http://technet.microsoft.com/en-us/library/ms171852.aspx

Samples

Delphi

MSQuery.CommandTimeout := 5; // wait 5 seconds for the command to execute
MSQuery.SQL.Text := 'long-lasting query';
try
  MSQuery.Execute;
except
  on E: EOLEDBError do begin
    if E.ErrorCode = DB_E_ABORTLIMITREACHED then // the 'Query timeout expired' error
      ShowMessage(E.Message);
    raise;
  end;
end;

C++Builder

MSQuery->CommandTimeout = 5; // wait 5 seconds for the command to execute
MSQuery->SQL->Text = "long-lasting query";
try
{
  MSQuery->Execute();
}
catch (EOLEDBError &E)
{
  if (E.ErrorCode == DB_E_ABORTLIMITREACHED) // the 'Query timeout expired' error
    ShowMessage(E.Message);
  throw;
}

See Also

© 1997-2024 Devart. All Rights Reserved. Request Support DAC Forum Provide Feedback