Examples: ConnectTo method

The following form action gets the name of a data source, as well as an optional user name and password, and attempts to connect to the 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
  Dim userName As String
  Dim password As String
  dataSource = Inputbox$ _
  ("Enter name of data source", "Data source?")
  userName = Inputbox$ _
  ("Enter user name, if required", "User name?")
  If userName = "" Then
    If Not con.ConnectTo(dataSource) Then
      Messagebox "Could not connect to " & dataSource
    End If
  Else
    password = Inputbox$("Enter password", "Password?")
    If Not con.ConnectTo(dataSource, _
    userName, password) Then
      Messagebox "Could not connect to " & dataSource
    End If
  End If
End Sub
Sub Queryclose(Source As NotesUIDocument, Continue As Variant)
  con.Disconnect
End Sub