View Products Sample -
Populate Dataset through ODP.NET using Visual Basic .NET
(VB.NET)
Table of Contents
The purpose of this sample application is to
demonstrate how to populate a DataSet through Oracle Data
Provider for .NET (ODP.NET) using VB.NET .
ODP.NET offers faster and reliable access to
Oracle Database by using Oracle Native APIs. ODP.NET provides
features to access any .NET application. The data access
through ODP.NET can be done using a collection of classes
contained in Oracle.DataAccess assembly. Figure 1.1 describes how data is accessed
using ODP.NET.

Figure 1.1 Data Access
Using ODP.NET
DataSet is a
major component of ADO.NET. It is an in-memory cache of the
data retrieved from the database. OracleDataAdapter
represents a set of data commands and a database connection
that is used to fill the DataSet based on
the query given. OracleCommand
represents SQL statements to execute against datasource. OracleConnection is used to build the database
connection.
This Visual Basic .NET (VB.NET) sample
application displays a product catalog for a product store.
When this sample is run, a list of products from database
appears in a DataGrid (in tabular
format). The DataGrid gets populated
from a DataSet which is filled by a
DataSource using OracleDataAdapter.
Hence demonstrating how to populate DataSet
through Oracle Data Provider for .NET (ODP.NET).
When this
sample application is run, a list of Products from database is
displayed as shown in figure 1.2, on clicking the 'Close'
button, the application gets closed.

Figure 1.2: Screen Shot for DataSet
Populate VB Sample
-
Visual Basic.NET
(VB.NET) installed with MS Development Environment 7.0
version (MS Visual Studio .NET) including MS .NET
Framework 1.0 version
-
Oracle8i Database or later running
SQL*Net TCP/IP listener (can be downloaded here )
-
Oracle Data Provider for .NET
(ODP.NET) (can be downloaded here )
Unzip DSPopulateVB.zip using Winzip or command utility
to your convenient directory referred
to as <Extract_Dir>. Extraction of the zip file
results in the creation of 'DSPopulateVB'
directory. Refer Description of Sample Files section
for more details.
Connect to your database as any user and
run the script <Extract_Dir>\DSPopulateVB\Setup\DatabaseSetup.sql
at the SQL prompt
SQL>
@<Extract_Dir>\DSPopulateVB\Setup\DatabaseSetup.sql
This script will prompt for the
username, password and connectstring. You may choose any
existing username. Products table will get
created in specified users schema.
1. Ensure that the Database setup
has been completed.
2. Open DSPopulateVB.sln using Visual Studio .NET from <Extract_Dir>\DSPopulateVB
folder.
3. Edit ConnectionParams.vb file to change the database
connection parameters like username, password and TNSNames
for the database.You need to input the same values of
connection parameters as given while doing the Database
Setup. Save this file.
4. Ensure that the
following .NET Component References have been added to DSPopulateVB project:
System,
System.Data,
System.Drawing,
System.Windows.Forms,
System.XML,
Oracle.DataAccess.
To add the above .NET
Components
a)Go to Menu ->View-> Solution Explorer.
b)Right click on DSPopulateVB project,
choose 'Add Reference'.
c)Choose the above .NET Components from the list displayed.
d)Click 'Select', then OK.
e) The chosen .NET component gets added to the project.
5. Build and
run the sample.
Following is the directory structure
of the DSPopulateVB.zip :
| Directory |
File Name |
Description |
DSPopulateVB\doc |
Readme.html |
This file |
| otn.css |
This is a cascading
stylesheet applied to Readme.html |
DSPopulateVB\doc\images |
*.gif |
This folder contains
images used in the Readme.html file |
DSPopulateVB\src |
ConnectionParams.vb |
This VB file contains
parameters for database connection |
| ViewProductsFrm.vb |
This VB file contains
source code for UI for sample application and its
functionality |
| DSPopulateVB.csproj |
VB project file |
| ViewProductsFrm.resx |
.NET XML Resource
Template (this file gets automatically generated when a
Visual Studio Project is created) |
| DSPopulateVB.sln |
Visual Studio Solution |
DSPopulateVB\Setup |
DatabaseSetup.sql |
This is a SQL script
file |
|