Allen's blog

Just do it
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

.NET oracle 各种连接字符串

Posted on 2008-04-28 13:21  allenlf  阅读(10775)  评论(1)    收藏  举报

OLE DB, OleDbConnection (.NET)
"Provider=msdaora;Data Source=TESTDB;User Id=chbo;Password=admin;"

OracleConnection (.NET)
"Data Source=TESTDB;User Id=chbo;Password=admin;Integrated Security=no;"

再加个ODBC的
"Driver={Microsoft ODBC for Oracle};Server=TESTDB;Uid=chbo;Pwd=admin;"

如果连接远程的,直接吧Data Source改成IP地址就行了,Oracle好像没有库的概念

 


Driver={Microsoft ODBC for Oracle};Server=myServerAddress;Uid=myUsername;Pwd=myPassword;

Old version
 
Driver={Microsoft ODBC Driver for Oracle};ConnectString=OracleServer.world;Uid=myUsername;Pwd=myPassword;

OLE DB, OleDbConnection (.NET)
Standard security
This connection string uses a provider from Microsoft. 
Provider=msdaora;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;

Standard Security
This connection string uses a provider from Oracle. 
Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;

Trusted Connection
 
Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;OSAuthent=1;

OracleConnection (.NET)
Standard
 
Data Source=MyOracleDB;Integrated Security=yes;

This one works only with Oracle 8i release 3 or later 

Specifying username and password
 
Data Source=MyOracleDB;User Id=myUsername;Password=myPassword;Integrated Security=no;

This one works only with Oracle 8i release 3 or later 
Missing the System.Data.OracleClient namespace? Download .NET Managed Provider for Oracle >>
Great article! "Features of Oracle Data Provider for .NET" by Rama Mohan G. at C# Corner >>
  
Omiting tnsnames.ora
This is another type of Oracle connection string that doesn't rely on you to have a DSN for the connection. 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. 
SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));uid=myUsername;pwd=myPassword;

 
Core Labs OraDirect (.NET)
Standard
 
User ID=myUsername;Password=myPassword;Host=ora;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;


Data Shape
MS Data Shape
 
Provider=MSDataShape.1;Persist Security Info=False;Data Provider=MSDAORA;Data Source=orac;User Id=myUsername;Password=myPassword;