Skip to content

TCustomConnection.Close

Close the connection.

Declaration

Source position: db.pas line 2266

public 
procedure TCustomConnection.Close(ForceClose: Boolean=False);

Description

Close closes the connection with the server if it was connected. Calling this method first triggers the BeforeDisconnect event. If an exception is raised during the execution of that event handler, the disconnect process is aborted. After calling this event, the connection is actually closed. After the connection was closed, the AfterDisconnect event is triggered.

Calling the Close method is equivalent to setting the Connected property to False.

If ForceClose is True then the descendent should ignore errors from the underlying connection, allowing all datasets to be closed properly.

Errors

If the connection cannot be broken for some reason, an EDatabaseError exception will be raised.

See also

Name Description
TCustomConnection.BeforeDisconnect Event triggered before a connection is closed.
TCustomConnection.AfterDisconnect Event triggered after a connection is closed.
TCustomConnection.Open Makes the connection to the server.
TCustomConnection.Connected Is the connection established or not.