.NET连接Oracle的方法

方式1:直接利用.NET的oracle驱动连接

引用System.data.oracleclient;

using System.data.oracleclient;

string oradb = "Data Source=water;User Id=modis;Password=modis;Integrated Security=no";

OracleConnection conn = new OracleConnection(oradb);

conn.Open();

 

 

方式2:安装完ODP.net(Oracle Data Provider.NET),通过OLEDB连接。

引用System.Data.OleDb;

using System.Data.OleDb;

string oradb = "Provider=OraOLEDB.Oracle;Data Source=water;User Id=modis;Password=modis;";

OleDbConnection myConnection = new OleDbConnection(oradb);

myConnection.Open();

 

 

方式3:安装完ODP.net,通过Oracle的连接器

引用动态链接库Oracle.DataAccess.Client.

using Oracle.DataAccess.Client;

string oradb = "Data Source=water;User Id=modis;Password=modis;";

OracleConnection conn = new OracleConnection(oradb); // C#

conn.Open();

05-11 20:46