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

Using OO4O Automation with Visual Basic

When accessing the OO4O automation server using the OLE Automation interface and Visual Basic, you must create each object explicitly, except for the client object, which is always created automatically. The following code fragment demonstrates how to first create all objects required by a dynaset and then the dynaset itself.

  1. Start Visual Basic and create a new project. From the Project menu, select References and check InProcServer 4.0 Type Library.

    Text description of the illustration o4o00003.gif follows

    Text description of the illustration o4o00003.gif

2. Start Visual Basic and create a new project, then add the following code to the Declarations section of a form.

...

' Declare variables

Dim OraSession As OraSession

Dim OraDatabase As OraDatabase

Dim OraDynaset As OraDynaset

Dim OraFields As OraFields

3. Add the following code to the Load procedure associated with the form to display the Oracle data.

' Create the OraSession Object. The argument to CreateObject is the

' name by which theOraSession object is known to the OLE system.

Set OraSession = CreateObject("OracleInProcServer.XOraSession")

' Create the OraDatabase Object by opening a

' connection to Oracle.

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

' Create the OraDynaset Object.

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

' You can now display or manipulate the data in the

' dynaset. For example:

Set OraFields = OraDynaset.fields

OraDynaset.movefirst

Do While Not OraDynaset.EOF

MsgBox OraFields("ename").Value

OraDynaset.movenext

Loop

End Sub

4. Run the form to view the results.

See Quick Tour with Visual Basic for more information on using OO4O with Visual Basic.

See Also


 
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