1.在本机安装了Oracle。安装时:
配置选项 选“创建数据库”;
数据库配置 选“一般用途/事务处理”;
全局数据库名 orcl
SID orcl
所有的账户(SYS、SYSTEM、SYSMAN、DBSNMP)都使用同一个口令“123”。
2.在本机还安装了PL/SQL Development。登录PL/SQL成功:
Usename: orcl
Database: ORCL123
Conect as: SYSDBA
问题:在本机 .NET中连接ORCL123,代码为:
public static void GetData()
{
OracleConnection conn = new OracleConnection("Data Source=ORCL123;User Id=orcl;Password=123;");
OracleDataAdapter apt = new OracleDataAdapter("select x1 from orcl.x1", conn);
apt.SelectCommand.CommandType = CommandType.Text;
DataSet ds = new DataSet();
apt.Fill(ds);
}
在一个页面BUTTON控件的Click()事件中调用GetData():
protected void Button1_Click(object sender, EventArgs e)
{
Processing.GetData();
}
运行时单击按钮Button1,出现错误信息:
“用户名/密码无效;拒绝登录”
为什么会拒绝登录(用同样的用户和密码登录PL/SQL Development成功)?是不是还需要在本机安装Oracle客户端?安装PL/SQL Development时会自动安装Oracle客户端吗?
配置选项 选“创建数据库”;
数据库配置 选“一般用途/事务处理”;
全局数据库名 orcl
SID orcl
所有的账户(SYS、SYSTEM、SYSMAN、DBSNMP)都使用同一个口令“123”。
2.在本机还安装了PL/SQL Development。登录PL/SQL成功:
Usename: orcl
Database: ORCL123
Conect as: SYSDBA
问题:在本机 .NET中连接ORCL123,代码为:
public static void GetData()
{
OracleConnection conn = new OracleConnection("Data Source=ORCL123;User Id=orcl;Password=123;");
OracleDataAdapter apt = new OracleDataAdapter("select x1 from orcl.x1", conn);
apt.SelectCommand.CommandType = CommandType.Text;
DataSet ds = new DataSet();
apt.Fill(ds);
}
在一个页面BUTTON控件的Click()事件中调用GetData():
protected void Button1_Click(object sender, EventArgs e)
{
Processing.GetData();
}
运行时单击按钮Button1,出现错误信息:
“用户名/密码无效;拒绝登录”
为什么会拒绝登录(用同样的用户和密码登录PL/SQL Development成功)?是不是还需要在本机安装Oracle客户端?安装PL/SQL Development时会自动安装Oracle客户端吗?
问题处在你这里的配置连接字符换。安装PL/SQL Development时会自动安装Oracle客户端吗?肯定不会了
连接字符串存在问题…