c#的代码,进行用户登录,显示没有语法错误,但是在进行运行的时候告诉我语法有错误,
这是我的代码:protected void Button1_Click(object sender, EventArgs e) { //设置数据库连接 SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["dingcooConn"]); conn.ConnectionString = ConfigurationManager.ConnectionStrings["dingcooConn"].ConnectionString; conn.Open(); //打开数据库链接 SqlCommand cmd = new SqlCommand(); cmd.CommandText = "select count(*) from User where UserID=@UserID and Password=@Password"; cmd.Connection = conn; //设置参数 SqlParameter paraUserID = new SqlParameter("@UserID", SqlDbType.NVarChar, 16); SqlParameter paraPassword = new SqlParameter("@Password", SqlDbType.NVarChar, 16); paraUserID.Value = txtUserID.Text; paraPassword.Value = txtUserPwd.Text; cmd.Parameters.Add(paraUserID); cmd.Parameters.Add(paraPassword); //返回查询结果值; int nCount = int.Parse(cmd.ExecuteScalar().ToString()); if (nCount> 0) { Session ["userid"]=paraUserID ; //将用户名放入session对象中 if (CheckBox1.Checked ==true) { string userid = txtUserID.Text; HttpCookie cookie1; if (Request.Cookies["user"] != null) {Response.Cookies["user"].Expires = DateTime.Now.AddMonths(2); //若cookie["user"]不为空,则把当前的用户名放入该cookie中, } else { cookie1 = new HttpCookie("user"); cookie1.Values.Add("userid",userid ); cookie1.Expires = DateTime.Now.AddMonths(2); Response.Cookies.Add(cookie1); //若cookie["user"]为空,新建cookie,并放入用户名,过期时间为两个月 } } else { return ; } Response.Redirect("default.aspx"); }