c# 连接数据库oracle 无效操作。连接被关闭
private void button1_Click(object sender, EventArgs e){
String name = this.textBox1.Text;
String password = this.textBox2.Text;
OracleConnection conn = new OracleConnection("server=materielSystem;uid=fengge;pwd=fengge");
conn.Open();
OracleCommand comm = new OracleCommand("select * from users where username= '"+name+"' and password = '"+password+"'");
OracleDataReader orReader = comm.ExecuteReader(); if (orReader.Read())
{
Console.WriteLine(orReader.GetString(1)+" "+orReader.GetString(2));
}
else
{
Console.WriteLine("用户名或密码有有误,请重新输入!");
this.textBox1.Focus();
}
}
当运行到红色的代码时出先“无效操作。连接被关闭”
------解决方案--------------------server=materielSystem;uid=fengge;pwd=fengge
这个有问题吧
没有指定数据库,只指定了服务器
Server=.;DataBase=JobBS;UID=sa;PWD=sa
加上数据库