2 lianshaohua110 lianshaohua110 于 2016.03.08 16:45 提问

.net连接oracle数据库

一、string strConnString = "Data Source=ORCL;User Id=admin;Password=ad
min;";

Oracle.DataAccess.Client.OracleConnection OraCnn = new Oracle.DataAccess.Client.OracleConnection();

OraCnn.ConnectionString = strConnString;

try

{ OraCnn.Open();

MessageBox.Show("连接成功");

}

catch (Exception ex)

{

MessageBox.Show(ex.Message);

}

finally

{ OraCnn.Dispose();

}
二、string strConnString = "Data Source=ORCL;User Id=admin;Password=admin;";

System.Data.OracleClient.OracleConnection OraCnn = new System.Data.OracleClient.OracleConnection(strConnString);

try

{

OraCnn.Open();

MessageBox.Show("连接成功");

}

catch (Exception ex)

{

MessageBox.Show(ex.Message);

}

finally

{

OraCnn.Dispose();

}
为什么“一”连接失败,显示错误消息“用户名或密码错误”,“二”可以登录成功?怎么解决呢?望各位大神赐教

1个回答

hnxcjsbzzysljf
hnxcjsbzzysljf   2016.10.08 01:36

ccess.Client.OracleConnection OraCnn = new Oracle.DataAccess.Client.OracleConnection();

OraCnn.ConnectionString = strConnString;

try

{ OraCnn.Open();

MessageBox.Show("连接成功");

}

catch (Exception ex)

{

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!