我写在这里但是不知道为什么就是不执行.
public void Admin_Login(Object sender, EventArgs E)
{
if (TextBox1.Text != Session["ValidateCode"].ToString())
{
Response.Write("<script>alert('验证码错误,请重新登陆!!')</sc" + "ri" + "pt/>");
}
else
{
if (source.Text == "")
{
Response.Write("<script>alert('密码不能为空!!')</sc" + "ri" + "pt/>");
}
//获取要加密的字段,并转化为Byte[]数组
byte[] data = System.Text.Encoding.Unicode
.GetBytes(source.Text.Trim().ToCharArray());
//建立加密服务
System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
//加密Byte[]数组
byte[] result = md5.ComputeHash(data);
//将加密后的数组转化为字段
string sResult = System.Text.Encoding.Unicode.GetString(result);
//作为密码方式加密
string EnPswdStr = System.Web.Security.FormsAuthentication.
HashPasswordForStoringInConfigFile(source.Text.ToString(), "MD5");
OleDbConnection cnn;
OleDbCommand cmd;
OleDbDataReader datar;
string sql, strcnn;
strcnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("App_Data/DataBase.mdb");
cnn = new OleDbConnection(strcnn);
cnn.Open();
sql = "select * from userG where userID='" + AdminID.Text + "' and userPWD='" + EnPswdStr + "'";
cmd = new OleDbCommand(sql, cnn);
datar = cmd.ExecuteReader();
if (datar.Read())
{
Session["userID"] = datar["userID"].ToString();
Session["userN"] = datar["userN"].ToString();
Session["sc"] = datar["sc"];
}
if (Session["userID"] != "" && Session["userID"] != null)
{
Response.Redirect("index.htm");
}
else
{
Response.Write("<script>alert('密码或用户名错误,请重新登陆!!')</sc" + "ri" + "pt/>");
Response.Redirect("admin_Login_A.aspx");
}
}
}
[此贴子已经被作者于2007-9-20 16:07:42编辑过]
人们笑我太疯癫...我笑人们太正经