Skip Headers

Oracle® Objects for OLE Developer's Guide
10g Release 1 (10.1)

Part Number B10118-01
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Master Index
Master Index
Go to Feedback page
Feedback

RecordSource Property Example

This example demonstrates the use of SQL bind variables (parameters) in the RecordSource property of the data control. To run this demonstration:

  1. Copy this code into the definition section of a form containing a data control named oradata1.
  2. Press F5.
Sub Form_Load ()

'Set the username and password.

oradata1.Connect = "scott/tiger"

'Set the databasename.

oradata1.DatabaseName = "ExampleDb"

'Refresh the data control without setting the

' RecordSource. This has the effect of creating

' the underlying database object so that parameters

' may be added.

oradata1.Refresh

'Set the RecordSource and use a SQL parameter.

oradata1.RecordSource = "select * from emp where job = :job"

'Add the job input parameter with initial value MANAGER.

oradata1.Database.Parameters.Add "job", "MANAGER", 1

'Refresh the data control.

'Only employees with the job MANAGER will be contained

'in the dynaset.

oradata1.Refresh

'Change the value of the job parameter to SALESMAN.

oradata1.Database.Parameters("job").Value = "SALESMAN"

'Refresh ONLY the recordset.

'Only employees with the job SALESMAN will be contained

' in the dynaset.

oradata1.Recordset.Refresh

End Sub