Examples: Connection property

This agent executes the stored procedure named SSELDEPT, which performs a simple query. The agent then displays the first row of the result set.

Sub Initialize
  Dim con As New ODBCConnection
  Dim res As New ODBCResultSet
  Dim rowvals As String
  REM Connect to data source
  con.ConnectTo(Inputbox("ODBC data source name", "DSN"))
  While Not con.IsConnected
    dsn = Inputbox("ODBC data source name", _
    "Connection not made ...")
    If dsn = "" Then Exit Sub
    con.ConnectTo(dsn)
  Wend
  Messagebox "Connected to " & con.DataSourceName,, _
  "Connection made ..."
  REM Call stored procedure
  Set res.Connection = con
  Call res.ExecProcedure("SSELDEPT")
  REM Display first row
  For i = 1 To res.NumColumns Step 1
    If res.IsValueNull(i) Then
      rowvals = rowvals & "NULL" & Chr(9)
    Else
      rowvals = rowvals & res.GetValue(i) & Chr(9)
    End If
  Next
  Messagebox rowvals,, "Value of first row"
  REM Disconnect
  con.Disconnect  
End Sub