Examples: Close method
This agent adds a new row to a table, then closes the table and re-executes the query to display the entire table, including the new row.
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
On Error Goto errorHandler
Set qry.Connection = con
Set result.Query = qry
con.ConnectTo("ATDB")
qry.SQL = "SELECT * FROM STUDENTS"
result.Execute
result.AddRow
Call result.SetValue("LASTNAME", _
Inputbox$("Last name?", "New student", "Rodriguez"))
Call result.SetValue("FIRSTNAME", _
Inputbox$("First name?", "New student", "Jorges"))
Call result.SetValue("STUDENT_NO", _
Cint(Inputbox$("Student number?", "New student",_
"9999")))
Call result.SetValue("ADDRESS", _
Inputbox$("Address?", "New student", "11 Rogers St."))
Call result.SetValue("CITY", _
Inputbox$("City?", "New student", "Cambridge"))
Call result.SetValue("STATE", _
Inputbox$("State?", "New student", "MA"))
Call result.SetValue("ZIP", _
Inputbox$("Zip?", "New student", "02142"))
Call result.SetValue("CR_TO_DATE", _
Cint(Inputbox$("Credits to date?", "New student", "0")))
result.UpdateRow
result.Close(DB_CLOSE)
result.Execute
msg = "Student names:" & Chr(10)
Do
result.NextRow
msg = msg & Chr(10)
For i = 1 To result.NumColumns
msg = msg & " " & result.GetValue(i)
Next
Loop Until result.IsEndOfData
Messagebox msg,, "Student data"
result.Close(DB_CLOSE)
con.Disconnect
Exit Sub
errorHandler:
Messagebox result.GetExtendedErrorMessage,, _
result.GetErrorMessage
Exit Sub
End Sub