A summary of the problems and methods of asp.net connecting Oracle

Source: Internet
Author: User

Introduction to two methods for. NET Oracle Databases
1. Install Oracle client, connect Oracle

The client and Server service names and connection strings need to be aligned in the client%oracle_client_home%network/admin/configuration Tnsnames.ora, with the service name AA as an example. The service name is configured for example:

The code is as follows Copy Code

A =
(DESCRIPTION =
(Address_list =
(address = (PROTOCOL = TCP) (HOST = Helen) (PORT = 1521))
)
(Connect_data =

(SERVER = dedicated)
(service_name = a)
)
)

Program code:

The code is as follows Copy Code

String Connora = "Data source=a;" User id=a;password=a; Unicode=true ";

OracleConnection conn = new OracleConnection (Connora);
Conn. Open ();
IF (Conn. state = = ConnectionState.Open)
Response.Write ("Dataoracle.aspx Conn Open success");
Else

Response.Write ("Dataoracle.aspx conn Open failure");


2. Do not install Oracle client, connect Oracle

You do not need to configure Tnsnames.ora to write the host, port, database ID (SID) to the connection string, and other connections are the same.

The new connection string is:

The code is as follows Copy Code

Data source= (DESCRIPTION = (Address_list = (address = (PROTOCOL = TCP) (HOST = Helen) (PORT = 1521)) (Connect_data = (SID = a))); User id=a;password=a; Unicode=true

The company uses oracle10g,vs2010, all 32-bit.

1 oracle10g in 64-bit Win7 can not be directly installed, the solution: in the installation of the boot EXE file right key to open the Properties menu, and then select Compatibility---> Check to run this program compatibility--> select WinXP, save can be installed.

2 before using the WINXP32 bit system, the connection string is like this

The code is as follows Copy Code

<add name= "SQLMembershipConnString2" connectionstring= "Data SOURCE=ORCL; User Id=system; password=123456 "providername=" Oracle.DataAccess.Client "/>

In exchange for now 64-bit Win7 has been unable to run, toss a day to know unexpectedly is the connection string problem. Hint of the error is that the Oracle client version is not high enough, no matter how the connection string changes are the same error prompts, Baidu found a lot of articles are said to lack of authority reasons (not sure whether there is this reason), changed after the same problem, this problem toss me a day of time!! , and then downloaded Oracle's odp.net components, 32-bit 64-bit of all kinds of toss, there are error prompts, the error prompted to search on the internet can not be solved. There are compatibility issues with the framework's classes and odp.net. Later, he looked at Odp.net's instructions, originally intended to be connected to a remote server, try to use

The code is as follows Copy Code

<add name= "SQLMembershipConnString3" connectionstring= "Data source= (description= (address=) (protocol=tcp 192.168.253.11) (port=1521)) (Connect_data= (SID=HZDB))); User id=test; password=123456 "providername=" Oracle.DataAccess.Client "/>

Such a string, because before a lot of changes in the reason, so also toss for a long time also did not connect, just I intend to give up the home to reload the 32-bit system, the brush page found that the error hint is "not found table or view", I am! Then we found the source of the problem: the connection string is wrong. Then it's normal to change into a System.Data.OracleClient.
The test found another way to do this:

The code is as follows Copy Code

<add name= "sqlmembershipconnstring" connectionstring= "Data source=
(DESCRIPTION =
(address = (PROTOCOL = TCP) (HOST = 192.168.253.128) (PORT = 1521))
(Connect_data =
(SERVER = dedicated)
(service_name = ORCL)
)
); User id=test; password=123456;
"Providername=" Oracle.DataAccess.Client "/>


About

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.