How to: Connect to an Oracle Database Using the SqlDataSource Control
You can use the SqlDataSource control to connect to an Oracle database. You connect the control to an Oracle database by first establishing connection information in the Web.config file, and then by referencing the connection information in a SqlDataSource control.
The System.Data.OracleClient provider requires Oracle client software version 8.1.7 or later to be installed on the computer that connects to the Oracle database; in this case, on the computer that runs ASP.NET pages.
To use the SqlDataSource control to connect to an Oracle database
Open the page from which you want to connect to an Oracle database.
Switch to Design view.
From the Data tab of the Toolbox, drag a SqlDataSource control onto your page.
If the SqlDataSource Tasks smart tag does not appear, right-click the control and click Show Smart Tag.
In the SqlDataSource Tasks list, click Configure Data Source.
In the Configure Data Source dialog box, click New Connection.
The Choose Data Source dialog box is displayed.
In the Data source list, click Oracle Database and then click Continue.
The Add Connection dialog box is displayed.
In the Server name box, type the name of the Oracle server.
Type the user name and password to connect with the database.
Select the Save my password box to save authentication information as part of the connection string, and then click OK.
If you include explicit authentication information in a connection string, you should encrypt the ConnectionStrings section of the Web.config file. For details, see Encrypting Configuration Information Using Protected Configuration.
You are returned to the Configure Data Source dialog with the new connection string information displayed.
Make sure that the Yes, save this connection check box is selected, change the name of the connection string if you want, and then click Next to have the connection string information saved in the application's Web.config file.
The Configure the Select Statement pane appears.
Click Specify a custom SQL statement or stored procedure if you want to type in your own SQL statement, or Specify columns from a table or view to use the wizard to create the query.
If you clicked Specify columns from a table or view, in the Name list click the name of the table or view to use, and then in the Columns list select the columns to return.
To generate update statements, click Advanced and then click Generate INSERT, UPDATE, and DELETE statements.
If you clicked Specify a custom SQL statement or stored procedure, click Next to move to the Define Custom Statements or Stored Procedures pane to write your query.
To define update statements, click the UPDATE, INSERT, and DELETE tabs and specify the SQL command or stored procedure to use for each operation.
Click the Test Query button to test your query against the database, and then click Finish.