日期:2014-05-17 浏览次数:20544 次
OracleConnection conn = new OracleConnection(ConnectionString); string sql = "select * from table_user where name=:name and pwd=:pwd"; OracleCommand cmd = new OracleCommand(sql, conn); OracleParameter name = new OracleParameter(":name", OracleType.Char, 50); name.Value = TextBox1.Text; cmd.Parameters.Add(name); OracleParameter pwd = new OracleParameter(":pwd", OracleType.Char, 50); pwd.Value = TextBox2.Text; cmd.Parameters.Add(pwd); conn.Open(); OracleDataReader dr = cmd.ExecuteReader(); if (dr.HasRows) { if (判断账号是否被禁用)//怎样得到这一列的值 { Response.Write("账号被禁用!"); } else { Response.Redirect("index.html"); } } else { Response.Write("用户名或密码错误!"); } conn.Close();
if (dr.HasRows) { dr.Read(); if (dr["forbidden"].ToString()=="禁用")//取值之前要Read { Response.Write("账号被禁用!"); } else { Response.Redirect("index.html"); } } else { Response.Write("用户名或密码错误!"); }
------解决方案--------------------
if (dr != null && dr.Read())
{
string s = dr["字段名"].ToString();
}