. Net connection string for accessing Oracle

Source: Internet
Author: User
Tags oracleconnection

Method 1: Use System. Data. oracleclient (you need to install the Oracle client and configure tnsnames. ora ).

Oracleconnectionstring: Data Source = orcl; user id = Scott; Password = tiger; persist Security info = false;


Method 2: Use oldedb to connect


Provider = oraoledb. oracle.1; user id = Scott; Password = tiger; Data Source = (description = (address_list = (address = (Protocol = TCP) (host = (Port = 1521 ))) (CONNECT_DATA = (SERVICE_NAME = orcl )))

It seems that oledbcommandtype does not correspond to the ref cursor of Oracle on msdn, so it is discarded,


Method 3: The Oracle client is required, but tnsnames. ora is not required.

Connection string oracleconnectionstring

User ID = Scott; Password = tiger; Data Source = (description = (address_list = (address = (Protocol = TCP) (host = (Port = 1521 ))) (CONNECT_DATA = (SERVICE_NAME = orcl )))

However, follow the Online Demo and often prompt:

An unprocessed "system. argumentexception" exception occurs in system. Data. oracleclient. dll.

Other information: Invalid Length for connection option 'data source', maximum length is 128.

Is the code wrong?


After calculation, what is the length of oracleconnectionstring over 180?

I gave some of the spaces and tried them one by one. The idea is enough.

If no exception exists, it won't be the length limit. I will add a space one by one. The result seems to be no more than 177 characters in length and can be connected? Is it true that Bt


String strconn = "User ID = Scott; Password = tiger; Data Source = (description = (address_list = (address = (Protocol = TCP) (host = (Port = 1521) (CONNECT_DATA = (SERVICE_NAME = orcl )))";
MessageBox. Show (strconn. length. tostring ());
System. Data. oracleclient. oracleconnection oraconn = new system. Data. oracleclient. oracleconnection (strconn );

Oraconn. open ();
MessageBox. Show (oraconn. state. tostring (); // 177
Catch (exception ex)
MessageBox. Show (ex. Message );
Oraconn. Close ();



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.