History |
FindFirst (database statements)
Purpose
Finds a record in a record set.
This method begins at the first record and moves forward through the record set until Condition evaluates to TRUE or the end of the record set is reached. Each time the record pointer is moved, Condition is re-evaluated.
If the condition does not evaluate to TRUE and the end of the record set is reached, the NoMatch flag is set to TRUE.
In order to prevent deadlock in asynchronous systems, Find requires server re-entrance for each move and evaluation of Condition. Re-entrance has a substantial amount of overhead and it is often faster and more effective to use the Filter method instead of a Find method.
Syntax
DBStatement.FindFirst (Condition)
Compliance:
Level 2
Example
Sub Main()
Dim cnct As DBConnection
Dim stmt As DBStatement
cnct.OpenConnection("MyDSN") 'Open the data source "MyDSN"
stmt.OpenStatement(cnct, dbKeyset, dbRowver)
stmt.ExecuteSQL ("SELECT * FROM MyTable")
'Starting from the first record in the recordset, find the first record which
'makes the condition CustNum = 12345 evaluate to TRUE.
stmt.FindFirst(stmt.Column("CustNum") = 12345)
If (stmt.NoMatch) Then 'Record was not found
Print "The customer does not exist in the database!"
Else
Print "Customer Information:"
Print "Customer Name: ";stmt.Column("CustName")
Print "Customer Phone: ";stmt.Column("CustAddr")
Print "Customer Last Contacted: ";stmt.Column("CustLastContact")
End If
stmt.CloseStatement
cnct.CloseConnection 'Close the connection
End Sub
| ||||