Examples: DeleteRow method

This agent deletes a row from a table.

Uselsx "*LSXODBC"
%INCLUDE "lsconst.lss"

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
  Set qry.Connection = con
  Set result.Query = qry
  con.ConnectTo("ATDB")
  qry.SQL = "SELECT * FROM STUDENTS"
  result.Execute
  studentID = Inputbox$ _
  ("ID of student to be deleted:", "Delete student")
  If studentID = "" Then
    Messagebox "No student ID entered",, _
    "Bogus student ID"
    Exit Sub
  End If
  If Not result.LocateRow(1, Cint(studentID)) Then
    Messagebox "No such student",, "Bogus student ID"
    Exit Sub
  End If
  For i = 1 To 9 ' Get values for columns 1 - 9
    msg = msg & "  " & result.GetValue(i)
  Next
  If Messagebox _
  ("Do you really want to delete this student?" _
  & Chr(10) & Chr(10) & msg, _
  MB_YESNO + MB_ICONQUESTION, _
  "Delete student") = IDYES Then
    result.DeleteRow("STUDENTS")
  End If
  result.Close(DB_CLOSE)
  con.Disconnect
End Sub