Uselsx "*LSXODBC"
Sub Initialize
Dim con As New ODBCConnection
Dim qry As New ODBCQuery
Dim result As New ODBCResultSet
Dim firstName As String
Dim lastName As String
Dim msg As String
If Not con.ConnectTo("ATDB") Then
Messagebox "Could not connect to ATDB",, _
"Error connecting"
Exit Sub
End If
Set qry.Connection = con
Set result.Query = qry
qry.SQL = "SELECT * FROM STUDENTS ORDER BY LASTNAME"
result.Execute
msg = "Student names:" & Chr(10)
If result.IsResultSetAvailable Then
Do
result.NextRow
firstName = result.GetValue("FIRSTNAME")
lastName = result.GetValue("LASTNAME")
msg = msg & Chr(10) & firstName & " " _
& lastName
Loop Until result.IsEndOfData
result.Close(DB_CLOSE)
Else
Messagebox "No data retrieved for STUDENTS",, _
"No data"
Exit Sub
End If
Messagebox msg,, "Student Names"
con.Disconnect
End Sub