In useASP. NETWhen developing applications, we will use databases. ASP. NET andOracleIs also relatively common. This document describes how to connect ASP. NET to an Oracle database. Follow these steps to connect ASP. NET to an Oracle database:
(1) install the oracle client tool.
(2) Open the tnsnames. ora file in the installation directory D: \ oracle \ product \ 10.2.0 \ client_1 \ NETWORK \ ADMIN and configure it as follows:
- TOPTEST =
-
- (DESCRIPTION =
-
- (ADDRESS_LIST =
-
- (ADDRESS = (PROTOCOL = TCP)(HOST = 10.122.10.9)(PORT = 1521))
-
- )
-
- (CONNECT_DATA =
-
- (SERVICE_NAME = toptest)
-
- )
-
- )
(4) Add a connection string to the web. config file, for example:
<Add name = "OracleConn" connectionString = "Data Source = TOPTEST; User ID = ds1; Password = ds1; Unicode = True" providerName = "System. Data. OracleClient"/>
If the program and the database are on the same computer, you can use this connection.
<Add name = "OracleConn" connectionString = "Data Source = 10.100.1.9; User ID = ds1; Password = ds1; Unicode = True" providerName = "System. Data. OracleClient"/>
(5) access the database using a connection string
Public static readonly string connectionString = ConfigurationManager. ConnectionStrings ["OracleConn"]. ConnectionString;
Follow these steps to access the Oracle database. ASP. NET will be able to access the Oracle database. This article will introduce you here and hope you will gain some benefits!