Oracle® Objects for OLE Developer's Guide 10g Release 1 (10.1) Part Number B10118-01 |
|
This example demonstrates the use of the FindFirst, FindNext, FindPrevious methods. Copy and paste this code into the definition section of a form. Then press F5.
Sub Form_Load ()
Dim OraSession As OraSession
Dim OraDatabase As OraDatabase
Dim OraDynaset As OraDynaset
Dim OraFields As OraFields
Dim FindClause As String
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase = OraSession.OpenDatabase("ExampleDb", "SCOTT/TIGER", 0&)
Set OraDynaset = OraDatabase.CreateDynaset("select * from emp where empno >= 7654 and empno <= 7844 ", ORADYN_NO_BLANKSTRIP)
Set OraFields = OraDynaset.Fields
OraDynaset.MoveFirst
'FindClause for job as MANAGER
FindClause = "job LIKE '%GER'"
OraDynaset.FindFirst FindClause
'NoMatch property set to true , if no rows found
If OraDynaset.NoMatch Then
MsgBox "Couldn't find rows "
else
MsgBox OraFields("ename").Value ' Should display BLAKE
OraDynaset.FindNext FindClause
MsgBox OraFields("ename").Value ' Should display CLARK
OraDynaset.FindPrevious FindClause
MsgBox OraFields("ename").Value ' Should display BLAKE
endif
End Sub