Oracle Objects for OLE
Release 9.2

Part Number A95895-01
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents

Master Index

Feedback

Creating a Dynaset

See Also
Quick Tour
Employee Form

Oracle Objects for OLE lets you browse and update data using an object called a dynaset. When you create the dynaset using the OraDatabase.CreateDynaset() method, you must specify a valid SQL select statement. DbCreateDynaset() returns a pointer to the result of the SQL select statement.

In our employee application example, we must create global dynaset to which the rest of the program has access. We can create a dynaset that selects all the rows from the "emp" table and assign the resulting dynaset to the global EmpDynaset variable as follows:

Set EmpDynaset = OraDatabase.CreateDynaset("select * from emp", 0&)

The 0& parameter is a bit flag option that specifies the default dynaset state. In the default state, Oracle Objects for OLE will set unset fields to NULL while adding records using DbAddNew. We prefer this behavior since our emp table has no column defaults defined. You can also specify other options to allow server column defaults when adding records. See the CreateDynaset Method for more details.

The code to connect to the server and to create a global dynaset is typically the first thing your Visual Basic application executes. In our example employee application, the Form_Load() procedure creates the OIP server, connects to the database, creates a global dynaset, and calls the function EmpRefresh to display the field values on the Employee form. The code for Form_Load() looks like:

Private Sub Form_Load()

'OraSession and OraDatabase are global

Set OraSession = CreateObject("OracleInProcServer.XOraSession")

Set OraDatabase = OraSession.OpenDatabase("Exampledb", "scott/tiger", 0&)

Set EmpDynaset = OraDatabase.CreateDynaset("select * from emp", 0&)

Call EmpRefresh

End Sub

The following variables are defined globally in EMP_QT.BAS:

Global OraSession As Object

Global OraDatabase As Object

Global EmpDynaset As Object


 
Oracle
Copyright © 1994, 2002 Oracle Corporation.

All Rights Reserved.
Go To Documentation Library
Home
Go To Product List
Book List
Go To Table Of Contents
Contents

Master Index

Feedback