Export (0) Print
Expand All

How to: Connect to an Oracle Database Using the SqlDataSource Control (Visual Studio)

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.

NoteNote

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

  1. Open the page from which you want to connect to an Oracle database.

  2. Switch to Design view.

  3. From the Data tab of the Toolbox, drag a SqlDataSource control onto your page.

  4. If the SqlDataSource Tasks smart tag does not appear, right-click the control and click Show Smart Tag.

  5. In the SqlDataSource Tasks list, click Configure Data Source.

  6. In the Configure Data Source dialog box, click New Connection.

    The Choose Data Source dialog box is displayed.

  7. In the Data source list, click Oracle Database and then click Continue.

    The Add Connection dialog box is displayed.

  8. In the Server name box, type the name of the Oracle server.

  9. Type the user name and password to connect with the database.

  10. Select the Save my password box to save authentication information as part of the connection string, and then click OK.

    NoteNote

    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.

  11. Click Next.

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

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

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

    NoteNote

    To generate update statements, click Advanced and then click Generate INSERT, UPDATE, and DELETE statements.

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

    NoteNote

    To define update statements, click the UPDATE, INSERT, and DELETE tabs and specify the SQL command or stored procedure to use for each operation.

  16. Click Next.

  17. Click the Test Query button to test your query against the database, and then click Finish.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft