为什么登录不行?
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
namespace csharptestbbs
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label Label3;
protected System.Data.SqlClient.SqlCommand sqlCommand1;
protected System.Data.SqlClient.SqlConnection sqlConnection1;
protected System.Web.UI.WebControls.Button Button2;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
private void Button1_Click(object sender, System.EventArgs e)
{
sqlCommand1.Connection.Open();
int flag=(int)sqlCommand1.ExecuteNonQuery();
sqlCommand1.Connection.Close();
sqlConnection1.Close();
if (flag>0)//用户存在
{
Session["username"]=TextBox1.Text;
Response.Redirect("main.aspx");
}
else
{
Label3.Text="输入错误";
TextBox1.Text="";
TextBox2.Text="";
}
}
}
}
请问为什么我输入正确的用户名和密码也是显示“输入错误”!!!