各位高手请帮忙
各位:我在制作登录&注册界面时,调试没有一错误;可填写用户名和密码,并点击确认按键后,出现如下错误:请指教,谢谢!
登录页面源代码如下:
public partial class CLogin : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.lblDate1.Text = DateTime.Now.ToString();
}
protected void btnLogin_Click(object sender, EventArgs e)
{
//从文件Web.config中读取连接字符串
string strconn = ConfigurationSettings.AppSettings["dsn"];
//连接本地计算机的HotelManageSys数据库
SqlConnection cn = new SqlConnection(strconn);
//构造SQL语句,检查CustomersInfo表中的用户名和密码是否正确
string mysql = "select * from CustomersInfo where CCode='" + tbxCCode.Text + "'and CPassword='" + tbxCPwd.Text + "'";
//创建SqlCommand对象
SqlCommand cm = new SqlCommand(mysql, cn);
cn.Open();
int flag = (int)cm.ExecuteScalar();
cn.Close();
if (flag > 0)
{
lblMessage.Text = "";
//保存当前用户名
Session["CCode"] = tbxCCode.Text;
lblMessage.Text = "欢迎您!" + Session["CCode"];
Response.Redirect("CustomersInfo.aspx");
}
else
{
lblMessage.Text = "对不起,您的登录名称/登录密码不正确,请重新输入";
}
}
protected void btnReg_Click(object sender, EventArgs e)
{
Response.Redirect("LReg.aspx");
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("LoadPass.aspx");
}
}