In-depth analysis of C # connection strings to Oracle databases

Source: Internet
Author: User
Tags oracleconnection

Two Methods: 1.IP+ SID method 2. Configure the Link Method
1. IP + SID
Copy codeThe Code is as follows: DbHelperOracle. connectionString = string. Format (@ "Data Source = (DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = {0}) (PORT = 1521 ))
)
(CONNECT_DATA =
(SID = {1 })
(SERVER = DEDICATED)
)
); User Id = {2}; Password = {3 };",
TxtDBServerIP. Text. Trim (), txtOracleSID. Text. Trim (), txtDBUserName. Text. Trim (), txtDBPassword. Text. Trim ());

In this way, you do not need to add link configuration information in Oracle Net Manager Management.
2. Configure the link method,
Add the link configuration information in the Oracle Net Manager Management, and write the following link string:Copy codeThe Code is as follows: Data Source = TORCL; User Id = myUsername; Password = myPassword;

For other connection methods, refer to the following:
Oracle connection string Summary
Oracle XE
Standard connection
Oracle XE (or "Oracle Database 10g Express Edition") is a simple and free version.
The syntax format is as follows:Copy codeThe Code is as follows: Driver = (Oracle in XEClient); dbq = 111.21.31.99: 1521/XE; Uid = myUsername; Pwd = myPassword;

ODBC
Connection Mode of the new version
The syntax format is as follows:
Copy codeThe Code is as follows: Driver = {Microsoft ODBC for Oracle}; Server = myServerAddress; Uid = myUsername; Pwd = myPassword;

Connection Mode of earlier versions
The syntax format is as follows:
Copy codeThe Code is as follows: Driver = {Microsoft ODBC Driver for Oracle}; ConnectString = OracleServer. world; Uid = myUsername; Pwd = myPassword

Ole db, OleDbConnection (. NET)
Standard secure connection
This connection method uses Provider from Microsoft.
The syntax format is as follows:
Copy codeThe Code is as follows: Provider = msdaora; Data Source = MyOracleDB; User Id = myUsername; Password = myPassword;

Trusted connection
The syntax format is as follows:
Copy codeThe Code is as follows: Provider = msdaora; Data Source = MyOracleDB; Persist Security Info = False; Integrated Security = Yes;

Standard secure connection
This connection method uses the Provider from Oracle.
The syntax format is as follows:
Copy codeThe Code is as follows: Provider = OraOLEDB. Oracle; Data Source = MyOracleDB; User Id = myUsername; Password = myPassword;

Trusted connection
The syntax format is as follows:
Copy codeThe Code is as follows: Provider = OraOLEDB. Oracle; Data Source = MyOracleDB; OSAuthent = 1;

The syntax format is as follows:Copy codeThe Code is as follows: Provider = OraOLEDB. oracle; Data Source = (DESCRIPTION = (CID = GTU_APP) (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = myHost) (PORT = myPort ))) (CONNECT_DATA = (SID = MyOracleSID) (SERVER = DEDICATED); User Id = myUsername; Password = myPassword;

Oracle. DataAccess. Client. OracleConnection
Standard connection
The syntax format is as follows:
Copy codeThe Code is as follows: Data Source = TORCL; User Id = myUsername; Password = myPassword;

Connections with integrated security
The syntax format is as follows:
Copy codeThe Code is as follows: Data Source = TORCL; Integrated Security = SSPI;

Connection with ODP. NET Without tnsnames. ora
The syntax format is as follows:
Copy codeThe Code is as follows: Data Source = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP) (HOST = MyHost) (PORT = MyPort) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = MyOracleSID); User Id = myUsername; Password = myPassword;

OracleConnection, Oracle Data Provider, ODP. NET, System. Data. OracleClient. OracleConnection
Standard connection
The syntax format is as follows:
Copy codeThe Code is as follows: Data Source = MyOracleDB; Integrated Security = yes

Only in Oracle8i release 3 or later
Specify the connection between user password and password
The syntax format is as follows:
Copy codeThe Code is as follows: Data Source = MyOracleDB; User Id = myUsername; Password = myPassword; Integrated Security = no;

This is another connection method that does not depend on your DNS. you create a connection string based on the format used in the tnsnames. ora file without the need to actually have one of these files on the client pc.
The syntax format is as follows:Copy codeThe Code is as follows: SERVER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = MyHost) (PORT = MyPort) (CONNECT_DATA = (SERVICE_NAME = MyOracleSID ))); uid = myUsername; pwd = myPassword;

Some reported problems with the one above and Visual Studio. Use the next one if you 've encountered problems.
The syntax format is as follows:Copy codeThe Code is as follows: Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP) (HOST = MyHost) (PORT = MyPort) (CONNECT_DATA = (SERVICE_NAME = MyOracleSID ))); user Id = myUsername; Password = myPassword;

Use connection pool
If the connection pool service cannot find a connection that completely matches the connection string, it will create a connection. If the connection can be found, it will be used again.
The syntax format is as follows:
Copy codeThe Code is as follows: Data Source = myOracleDB; User Id = myUsername; Password = myPassword; Min Pool Size = 10; Connection Lifetime = 120; Connection Timeout = 60; Incr Pool Size = 5; decr Pool Size = 2;

Windows Verification
The syntax format is as follows:
Copy codeThe Code is as follows: Data Source = myOracleDB; User Id = /;

Privileged connection
Use the SYSOPER privilege
The syntax format is as follows:
Copy codeThe Code is as follows: Data Source = myOracleDB; User Id = SYS; Password = SYS; DBA Privilege = SYSOPER;

Use a password to terminate a function
When the connection is opened for the first time, a password expiration error is thrown after the link is opened. capture this error and run the OpenWithNewPassword command to set a new password.
The syntax format is as follows:Copy codeThe Code is as follows: Data Source = myOracleDB; User Id = myUsername; Password = myPassword;
OConn. OpenWithNewPassword (sTheNewPassword );

Proxy Verification
The syntax format is as follows:
Copy codeThe Code is as follows: Data Source = myOracleDB; User Id = myUsername; Password = myPassword; Proxy User Id = pUserId; Proxy Password = pPassword

Core Labs OraDirect (. NET)
Standard connection
Copy codeThe Code is as follows:
User ID = myUsername; Password = myPassword; Host = ora; Pooling = true; Min Pool Size = 0; Max Pool Size = 100; Connection Lifetime = 0;

Data Shape
MS Data ShapeCopy codeThe Code is as follows:
Provider = MSDataShape.1; Persist Security Info = False; Data Provider = MSDAORA; Data Source = orac; User Id = myUsername; Password = myPassword;

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.