Examples: Disconnect method

The following button disconnects from any current data source and then connects to a user-specified data source.

Uselsx "*LSXODBC"
Dim con As ODBCConnection
Sub Postopen(Source As Notesuidocument)
  Set con = New ODBCConnection
End Sub
Sub Click(Source As Button)
  Dim dataSource As String
  If con.IsConnected Then
    If Not con.Disconnect Then
      Messagebox "Disconnect failed from "  _
      & con.DataSourceName
    End If
  End If
  dataSource = Inputbox$("Enter name of data source", _
  "Data source?")
  If Not con.ConnectTo(dataSource) Then
    Messagebox "Could not connect to " & dataSource
  End If
End Sub
Sub Queryclose(Source As NotesUIDocument, Continue As Variant)
  If con.IsConnected Then con.Disconnect
End Sub