Manipulate Products Sample
- DML Operations on DataSet Through ODP.NET Using C#
Table of Contents
The purpose of this sample application is to demonstrate
how Data Manipulation Language (DML) operations on DataSet can be done
through Oracle Data Provider for .NET (ODP.NET) using C#.
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.

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 are 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.
When this C# sample is run, a list of existing
products from database appears in a tabular format. The user can change
product details by overwriting existing values. To insert new product
details the user can navigate to the end of the table and enter new product
details. When data in the DataGrid (Data
displayed in tabular format) is changed, the changes can be saved by clicking
the 'Save' button. The 'Update' method of the OracleDataAdapter
is called to resolve changes from DataSet
back to the data source, therefore commiting the changes. This demonstrates
DML operations on a 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, The user can add new products by appending new data
in the DataGrid displayed, also the user can update the existing data
for products by overwriting the existing values. To commit changes the
user can click the 'Save' button. On clicking the 'Close' button,
the application gets closed.

Figure 1.2: Screen shot for Manipulate Products Sample
-
Visual C# 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 DMLOperOnDS.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 'DMLOperOnDS'
directory. Refer Description
of Sample Files section for more details.
Connect to your database as
any user and run the script <Extract_Dir>\DMLOperOnDS\Config\DatabaseSetup.sql
at the SQL prompt
SQL>
@<Extract_Dir>\DMLOperOnDS\Config\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 DMLOperOnDS.sln
using Visual Studio .NET from <Extract_Dir>\DMLOperOnDS
folder.
3. Edit ConnectionParams.cs
file to change the database connection parameters i.e.Username, Password,
TNSName for 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 DMLOperOnDS 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 DMLOperOnDS 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 DMLOperOnDS.zip
:
| Directory |
File Name |
Description |
DMLOperOnDS\doc |
Readme.html |
This file |
| otn.css |
This is a cascading stylesheet applied
to Readme.html |
DMLOperOnDS\doc\images |
*.gif |
This folder contains images used in
the Readme.html file |
DMLOperOnDS\ |
DMLOperOnDS.sln |
Visual Studio Solution |
| DMLOperOnDS.suo |
Solution User option (this file gets
automatically generated when a Visual Studio Solution is created). |
DMLOperOnDS\src\DMLOperOnDS\ |
ConnectionParams.cs |
This C# file contains parameters for
database connection |
| ManipulateProducts.cs |
This C# file contains source code
for UI for sample application and its functionality |
| DMLOperOnDS.csproj |
C# project file |
| DMLOperOnDS.csproj.user |
Visual Studio Project User Options
(this file gets automatically generated when a Visual Studio Project
is created) |
| ManipulateProducts.resx |
.NET XML Resource Template (this file
gets automatically generated when a Visual Studio Project is created) |
DMLOperOnDS\Config |
DatabaseSetup.sql |
This is a SQL script file |
|