Disconnect Method for LCConnection

This method disconnects from a data source. Any existing result set is cleared. For example, this method terminates the connection to DB2® established by the Connect method. Only the connection and state are terminated, in order that reconnection may occur.

A disconnect also happens automatically when the LCConnection object is no longer allocated.

Because disconnecting may involve automatic commit or rollback (depending on the connector type and the settings of the database in question), this method may fail with an error.

Note: Since some connections may commit changes when disconnected, while others may roll back changes, it's probably best to use the Action method to commit or roll back changes yourself if you're in any doubt.
Note: If your program enables connection pooling, the connection will remain active in the pool even after you explicitly call Disconnect. In this case, automatic commit or rollback will not occur, and you must manually commit or revoke any changes you have made.

Defined In

LCConnection

Syntax

Call lcConnection.Disconnect

Example

Option Public
Uselsx "*lsxlc" 

Sub Initialize
  Dim connect As New LCConnection ("db2")  

  ' set appropriate properties to connect to DB2
  connect.Database = "Gold"
  connect.Userid = "JDoe"
  connect. Password = "DBINST1"

  ' connect to DB2 then disconnect
  connect.Connect
  Print "Successfully connected to DB2."

  ' now lets disconnect
  connect.Disconnect
  Print "Successfully disconnected from DB2."
End Sub

Example Output

Successfully connected to DB2.
Successfully disconnected from DB2.