[Overview][Constants][Types][Classes][Procedures and functions][Index] | Reference for unit 'db' (#fcl)

# TCustomConnection.Close

Close the connection

## Declaration

Source position: db.pas line 1863

`public procedure TCustomConnection.Close;`

## 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.

## Errors

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

## See also

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

The latest version of this document can be found at lazarus-ccr.sourceforge.net .