EPUB | CHM | PDF

TPSQLDatabase.Methods.Reset

Top Previous Next

Resets the communication channel to the server.

Syntax:

procedure Reset;

Description:

This function will close the connection to the server and attempt to reestablish a new connection to the same server, using all the same parameters previously used. This may be useful for error recovery if a working connection is lost.

Before calling Reset, TPSQLDatabase must be Connected to server. This means that TPSQLDatabase.Open method was called before, or property Connected was set to True. If an application calls Reset and there was no active connection, an exception is raised.

Example:

This example allows to trace connection problem inside an application and make reconnect on demand. Put TApplicationEvents component from Additional palette page on form, and then create OnException event handler:

procedure TForm1.ApplicationEvents1Exception(Sender: TObject;
  E: Exception);
begin
  If (E is EDatabaseError) and (PSQLDatabase1.TransactionStatus = trstUNKNOWN) then //this means we have bad connection
     PSQLDatabase1.Reset;
end;