Show: Delphi C++
Display Preferences

Disconnecting from a Database Server

From RAD Studio
Jump to: navigation, search

Go Up to Controlling Connections


There are two ways to disconnect a server using a connection component:

Calling Close sets Connected to False.

When Connected is set to False, the connection component generates a Data.DB.TCustomConnection.BeforeDisconnect event, where you can perform any cleanup before the connection closes. For example, you can use this event to cache information about all open datasets before they are closed.

After the BeforeConnect event, the connection component closes all open datasets and disconnects from the server.

Finally, the connection component generates an Data.DB.TCustomConnection.AfterDisconnect event, where you can respond to the change in connection status, such as enabling a Connect button in your user interface.

Note: Calling Close or setting Connected to False disconnects from a database server even if the connection component has a KeepConnection property that is True.

See Also

Code Examples

Personal tools
RAD Studio 10.2 Tokyo
In other languages
Previous Versions
Assistance