Introduction
This article is intended to illustrate one of the most common business scenarios such as displaying data from Oracle database on a form in a Windows application using DataSet objects and .NET Framework Data Provider for Oracle. I want to attend some questions about this topic. This walkthrough creates a simple form displaying data from emp table in Oracle database system which stores information about the employee entity.
Getting started.
Step 1. Create the Windows Application project.
From the File|New|Project main menu, go to New Project windows and enter the project name, the location.
Step 2. Create a connection to Oracle database system.
- In the Server Explorer windows, right click on Data Connections and select Add Connection.. from the context menu.
- In the Add Connection windows, enter the associated net service name, and the credentials to connect as show in figure 1. Prior connecting to the database server that you should have installed the Oracle client suite and configured the Net Service Names in the file tnsnames.ora in your local ORACLE_HOME\network\admin directory or using the Net Manager tool.
Figure 1. Adding a connection to the Oracle database system.
Step 3. Create the data source.
- In the Data Sources windows, select Add New Data Source.
- Select Database on the Choose a Data Source Type page, and click Next.
- On the Choose your Data Connection page, select the connection created in the step 2. You can either include or exclude sensitive data. Click Next.
- On the Save the Connection String to the Application Configuration file page, check Yes, and enter a name for the configuration value.
- On the Choose your Database Objects page, expand the tables and select the emp table and enter a name for the DataSet such as EmployeeDS. Finally click on Finish. Then the DataSource object is created. You can access to its definition, by double-clicking on EmployeeDS.xsd file, and opening the DataSet designer as shown in Figure 2.
Figure 2. The DataSet designer in Visual Studio.NET.
Step 4. Creating the form.
- From the Data Sources windows, drag and drop the item EMP onto the main form in your application. Then data-bound controls with descriptive labels appear on the form along with a BindingNavigator object.
Step 5. Running the application.
- Please press F5 key, and see the application as shown in Figure 3.
Conclusion
This is simple example to develop a client application to an Oracle database system. You can add more functionality depending on your requirements.