Oracle
ODBC 方式
New version:
"Driver={Microsoft ODBC for Oracle};Server=OracleServer.world;Uid=Username;Pwd=****;"
Old version:
"Driver={Microsoft ODBC Driver for Oracle};ConnectString=OracleServer.world;Uid=myUsername;Pwd=myPassword;"
评价:ODBC连接速度较慢,技术层次属低层。
OracleConnection方式
标准:
Data Source=MyOracleDB;Integrated Security=yes;
指明 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.
using System.Data.OracleClient; OracleConnection oOracleConn = new OracleConnection(); oOracleConn.ConnectionString = "my connectionstring"; oOracleConn.Open();
OLEDB, OleDbConnection (.NET)
Standard Security:
Provider=msdaora;Data Source=MyOracleDB;User Id=UserName;Password=asdasd;
this one's from Microsoft, the following is from Oracle.
Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;User Id=Username;Password=asdasd;"
Trusted Connection:
Provider=OraOLEDB.Oracle;Data Source=MyOracleDB;OSAuthent=1b; //from Oracle.
说明:OLEDB是微软的战略性的通向不同的数据源的低级应用程序接口。不会出现上文中OracleConnection中出现异常。
Code:
using System.Data.OleDb; OleDbConnection connection = new OleDbConnection(connectionString); connection.Open(); OleDbCommand command = new OleDbCommand(sql); command.Connection = connection; OleDbDataReader reader = command.ExecuteReader();
http://www.connectionstrings.com/oracle
http://blog.donews.com/kevinhlj/archive/2007/03/15/1140555.aspx