RAD Studio
ContentsIndex
PreviousUpNext
Disconnecting from a Database Server

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

  • Set the Connected property to False.
  • Call the Close method.
Calling Close sets Connected to False

When Connected is set to False, the connection component generates a 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 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.

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!