Examples: AddRow method

This agent adds a new row to a table.

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)
  con.Disconnect
  Exit Sub
errorHandler:
  Messagebox result.GetExtendedErrorMessage,, _
  result.GetErrorMessage
  Exit Sub
End Sub