If不成功,不执行Else了!!怎么办??
自己做的login.aspx 其中代码如下using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string constring = "provider=microsoft.jet.oledb.4.0;data source=" + Server.MapPath(".") + "//db.mdb";
OleDbConnection con = new OleDbConnection(constring);
string sql = "select * from users where name='" + name.Text.ToString() + "'";
OleDbCommand com = new OleDbCommand(sql, con);
com.Connection.Open();
OleDbDataReader dr;
dr = com.ExecuteReader();
while (dr.Read())
{
if (dr[2].ToString() == password.Text)
{
Session["name"] = name.Text;
Response.Redirect("index.aspx");
}
else
Response.Redirect("error.aspx");
}
}
protected void name_TextChanged(object sender, EventArgs e)
{
}
protected void Button2_Click(object sender, EventArgs e)
{
name.Text = string.Empty;
password.Text = string.Empty;
}
}
目前的问题是..我写的是,如果密码输入错误,则跳转到error.aspx.但是执行后,密码输入错误.也一点反应没有,只是停留在login.aspx.请大家帮忙看看怎么回事,谢谢了!!
name和password是文本框
button1是登陆按钮
button2是重置按钮