Examples: QueryExecuteTimeOut property

The following agent sets a five-second time-out on executing an SQL query.

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
  Set qry.Connection = con
  Set result.Query = qry
  con.ConnectTo("ATDB")
  qry.SQL = "SELECT * FROM STUDENTS ORDER BY LASTNAME"
  qry.QueryExecuteTimeOut = 5
  result.Execute
  msg = "Student names:" & Chr(10)
  If result.IsResultSetAvailable Then
    Do
      result.NextRow
      firstName = result.GetValue("FIRSTNAME", _
      firstName)
      lastName = result.GetValue("LASTNAME", _
      lastName)
      msg = msg & Chr(10) & firstName & " " & _
      lastName
    Loop Until result.IsEndOfData
  Else
    Messagebox "Cannot get result set for STUDENTS"
    Exit Sub
  End If
  Messagebox msg,, "Student Names"
  con.Disconnect
End Sub