Asp. NET Connect to Oracle Database

Source: Internet
Author: User

This period of time to maintain a customer's system, the system uses the Oracle database, previously developed using MSSQL, and did not use Oracle. Although these two databases are relational databases, the specific operation is very different, here is the record.

Connection string: <add name= "ConnectionString"  connectionstring= "password=qswd2015; User id=qswd;data source= (description= (address_list= (address=) (PROTOCOL=TCP) (host=192.168.1.22)) ( Connect_data= (server=dedicated) (SERVICE_NAME=ORCL)) "Providername=" System.Data.OracleClient "/>
Name: This is the way to get the connection string from the Web. config in the program.

Password:oracle the password for the database user.
User Id:oracle The account number of the database users.
PROTOCOL=TCP: Connection mode, generally without modification, TCP.
The IP address of the host=192.168.1.22:oracle server, or the hostname, can also be used if your Web server and Oracle database are local. or 127.0.0.1.
Port=1521:oracle database default port number.
SERVICE_NAME=ORCL database service name (does not know if this is the meaning), the database name you want to connect to.
Get the string in the program:
public static string connectionString = configurationmanager.connectionstrings["connectionString"]. ConnectionString;

The above is the connection string and how to get the connection string, followed by a few holes encountered:

1. First download the Oracle Client tool, this is necessary to connect Oracle data to develop the client must be installed;

2. It is best to install an Oracle database tool, such as plsql, test the connection situation, query data;

3. Test the connection is not a problem, the program connection prompt service name or connection problem, etc., please check whether the connection string is written correctly;

4. If you are installing a 64-bit system, and you choose the default installation when installing VS, the VS installation directory will select the installation path for program Files (x86), which is problematic for Oracle because it is present and will be prompted when connecting to Oracle " The connection is not open. (Very pit daddy's setting)

5. If you encounter the situation in 4, you can choose to reload vs or follow the workaround in http://www.cnblogs.com/xiaojinhe2/archive/2013/09/13/3318718.html.

Finally, the settings in the Tnsnames.ora are included, and Plsql will be used.

# # Configuration Description: #--xieheng_192.168.16. 20 refers to the network service name, can be named by the Sid_host (according to personal habits) #--host refers to the Oracle server machine name or ip#-port refers to the ports, The default is 1521#--Xieheng refers to Oracle's sid#--server = dedicated do not change # Please refer to the following connection example ORCL = (DESCRIPTION = (address_list = (ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.1.22) (PORT = 1521))) (Connect_data = (service_name = ORCL) ) )

  

Asp. NET Connect to Oracle Database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.