Walkthrough: Displaying Data From Oracle Database in a Windows Application


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.

  1. In the Server Explorer windows, right click on Data Connections and select Add Connection.. from the context menu.
  2. 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.

  1. In the Data Sources windows, select Add New Data Source.
  2. Select Database on the Choose a Data Source Type page, and click Next.
  3. 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.
  4. On the Save the Connection String to the Application Configuration file page, check Yes, and enter a name for the configuration value.
  5. 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.

  1. 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.

  1. Please press F5 key, and see the application as shown in Figure 3.


This is simple example to develop a client application to an Oracle database system. You can add more functionality depending on your requirements.

Up Next
    Ebook Download
    View all
    View all