Examples: HasRowChanged method

This example contains an action (the Click sub) that updates a row. Before the update occurs, a check is made to see if another program updated the row since this program fetched it.

Uselsx "*LSXODBC"
Dim con As ODBCConnection
Dim qry As ODBCQuery
Dim result As ODBCResultSet

Sub Postopen(Source As Notesuidocument)
  Set con = New ODBCConnection
  Set qry = New ODBCQuery
  Set result = New ODBCResultSet
  Set qry.Connection = con
  Set result.Query = qry
  con.ConnectTo("ATDB")
  qry.SQL = "SELECT * FROM STUDENTS ORDER BY LASTNAME"
  result.Execute
  ...
End Sub

Sub Click(Source As Button)
  Dim workspace As New NotesUIWorkspace
  Dim uidoc As NotesUIDocument
  Set uidoc = workspace.CurrentDocument
  Call result.SetValue("STUDENT_NO", _
  Cint(uidoc.FieldGetText("Student_No")))
  Call result.SetValue("FIRSTNAME", _
  uidoc.FieldGetText("FirstName"))
  Call result.SetValue("LASTNAME", _
  uidoc.FieldGetText("LastName"))
  Call result.SetValue("ADDRESS", _
  uidoc.FieldGetText("Address"))
  Call result.SetValue("CITY", _
  uidoc.FieldGetText("City"))
  Call result.SetValue("STATE", _
  uidoc.FieldGetText("State"))
  Call result.SetValue("ZIP", _
  uidoc.FieldGetText("Zip"))
  Call result.SetValue("PHONE", _
  uidoc.FieldGetText("Phone"))
  Call result.SetValue("CR_TO_DATE", _
  uidoc.FieldGetText("Cr_to_date"))
  If result.HasRowChanged Then
    If Messagebox("Someone else changed this row " & _
    "after you fetched it. " & _
    "Do you want to proceed?", MB_YESNO, _
    "Row was changed!") <> IDYES Then
      Exit Sub
    End If
  End If
  result.UpdateRow
End Sub

Sub Queryclose(Source As Notesuidocument, Continue As Variant)
  result.Close(DB_CLOSE)
  con.Disconnect
End Sub