连接Oracle数据库
先将System.Data.OralceClient.dll文件拷贝项目目录的Bin目录下,通常位于C:/windows/Microsoft.NET/Franmework/v.1.1.4322目录中.
//连接字符串
string Oracle_ConnStr = "Data Source=Oracle9i;Integrated Security=yes";
//创建OralceConnection对象
OralceConnection Conn= new OralceConnection(Oracle_ConnStr);
try
{
Conn.Open();
Label1.Text="连接到Oralce数据库";
}
catch(Exception ex)
{
Label1.Text=ex.ToString();
}
finally
{
//关闭数据库连接
Conn.Close();
}
//Oracle数据库ODBC连接字符串
string ODBC_Conn="Driver=Microsoft ODBC for Oracle;Server=OracleServer.Name;Uid=username;Pwd=password;";
//Oracle数据库OLEDB方式连接字符串
string OLEDB_Conn="Provider=OraOLEDB.Oracle;Data Source=myOracleDB;User Id=username;Password=password;";