登陆的页面能预览,但登陆正确后后,为何不能跳转呢?
代码如下:
        SqlCommand cmd = new SqlCommand("select count(id) from userinfo where username= @username and   
       [password] = @password", conn);
        cmd.Parameters.AddWithValue("@username", TextBoxUid.Text);
        cmd.Parameters.AddWithValue("@password", TextBoxPwd.Text);
        conn.Open();        int iCount=Convert.ToInt32(cmd.ExecuteScalar());
        if (iCount > 0)
        {            Response.Redirect("index.aspx");        }
        else
        {
            LabelErrMsg.Text = "error.aspx";
        }

解决方案 »

  1.   

    select count(id) from userinfo where username= @username and  
          [password] = @password", conn); 
    "select * from userinfo where username= @username and  [password] = @password"
    你的条件要的那么具体查出的一定是一条记录
    第1就用×去查就行了
    第2 int iCount=cmd.ExecuteNonQuery();
    就好了再跟就去看看
      

  2.   


       try
            {
                Response.Redirect("default.aspx");
            }
            catch(Exception error)
            {
                Response.Write(error.Message);
            }楼主试下上面的代码
    Response.Redirect
    不能放置于try catch 语句中
    至少一般情况下不可以这样。所以我怀疑楼主的Response.Redirect是不是在 try catch 中