我这样连接oracle数据库对吗?
在ASP.net
if(tbxusername.Text!= " "||tbxuserpwd.Text!= " ")
{
objconn=new OracleConnection(ConfigurationSettings.AppSettings[ "CnStirng "]);
//string conn= "select * from login ";
objconn.Open();
strSQl= "select username from login where username= ' "+tbxusername.Text.ToString()+ " 'and userpsw= ' "+tbxuserpwd.Text.ToString()+ " ' ";
objcmd=new OracleCommand(strSQl,objconn);
OracleDataReader dr=objcmd.ExecuteReader();
if(dr.Read())
{
Session[ "username "]=dr[ "username "].ToString();
Page.Response.Redirect( "welcome.aspx ");
}
else
{
this.lblerr.Text= "用户名or密码输入错误,请重新输入 ";
this.tbxusername .Text = " ";
this.tbxuserpwd.Text= " ";
}
}
我在运行的时候没有错误.可是当我输入用户名的时候.一点就出现错误了.
行 89: objconn=new OracleConnection(ConfigurationSettings.AppSettings[ "CnStirng "]);
行 90: objconn.Open();
行 91: strSQl= "select username from login where username= ' "+tbxusername.Text.ToString()+ " 'and userpsw= ' "+tbxuserpwd.Text.ToString()+ " ' ";
行 92: objcmd=new OracleCommand(strSQl,objconn);
说是90那行出现错误.
------解决方案--------------------open出错一般是连接字符串的问题