Uselsx "*LSXODBC"
(Globals) (Declarations)
Dim con As ODBCConnection
Dim dataSources As Variant
Dim tables As Variant
Dim thisdsn As Integer
Dim thistable As Integer
Dim workspace As NotesUIWorkspace
Dim uidoc As NotesUIDocument
Sub Postopen(Source As Notesuidocument)
Set workspace = New NotesUIWorkspace
Set uidoc = workspace.CurrentDocument
Set con = New ODBCConnection
con.SilentMode = True
dataSources = con.ListDataSources
thisdsn = Lbound(dataSources)
Call uidoc.FieldSetText("dataSource", & _
dataSources(thisdsn))
tables = con.ListTables(dataSources(thisdsn))
If Ubound(tables) <> 0 Then
thistable = Lbound(tables)
Call uidoc.FieldSetText("Table", & _
tables(thistable))
End If
End Sub
Sub Queryclose(Source As Notesuidocument, Continue As Variant)
If con.IsConnected Then
con.Disconnect
End If
End Sub
REM "Data source" button
Sub Click(Source As Button)
If thisdsn = Ubound(dataSources) Then
thisdsn = Lbound(dataSources)
Else
thisdsn = thisdsn + 1
End If
Call uidoc.FieldSetText("dataSource", & _
dataSources(thisdsn))
tables = con.ListTables(dataSources(thisdsn))
If Ubound(tables) <> 0 Then
thistable = Lbound(tables)
Call uidoc.FieldSetText("Table", & _
tables(thistable))
End If
End Sub
REM "Table" button
Sub Click(Source As Button)
If Ubound(tables) <> 0 Then
If thistable = Ubound(tables) Then
thistable = Lbound(tables)
Else
thistable = thistable + 1
End If
Call uidoc.FieldSetText("Table", tables(thistable))
End If
End Sub
REM "List tables" action
Sub Click(Source As Button)
Dim msg As String
con.ConnectTo(dataSources(thisdsn))
If con.IsConnected Then
fields = con.ListFields(tables(thistable))
If Ubound(fields) <> 0 Then
msg = tables(thistable) & _
" contains the following fields:" & Chr(10)
For o% = Lbound(fields) To Ubound(fields)
msg = msg & Chr(10) & fields(o%)
Next
Messagebox msg,, con.DataSourceName
Else
Messagebox "No fields in " _
& tables(thistable),, _
con.DataSourceName
End If
con.Disconnect
End If
End Sub
REM "List procedures" action
Sub Click(Source As Button)
Dim msg As String
con.ConnectTo(dataSources(thisdsn))
If con.IsConnected Then
procs = con.ListProcedures
If Ubound(procs) <> 0 Then
msg = con.DataSourceName & _
" contains the following procedures:" _
& Chr(10)
For o% = Lbound(procs) To Ubound(procs)
msg = msg & Chr(10) & procs(o%)
Next
Messagebox msg,, con.DataSourceName
Else
Messagebox "No procedures",, _
con.DataSourceName
End If
con.Disconnect
End If End Sub