Oracle® Objects for OLE Developer's Guide 10g Release 1 (10.1) Part Number B10118-01 |
|
This example demonstrates the use of SQL bind variables (parameters) in the RecordSource property of the data control. To run this demonstration:
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