我想做一个登入页面,看北大青鸟的教程用count来判断.
不知道有没有更好的办法?
我是用C#写的!想不出什么办法!帮个忙!没分!
又没有人能帮忙!

解决方案 »

  1.   

    ParameterDirection.ReturnValue用个这个没有
      

  2.   

    我贴下源码吧!我实在是判断不下去了!
    SqlConnection con=db.con();
    con.Open();
    SqlCommand cmd=new SqlCommand("select * from user where username='"+txtusername.Text+"' and userpwd='"+txtuserpwd+"'",con);
    //然后就判断不知道如何判断....
    如果相同就执行
    this.Panel1.Visible=false;
    this.Panel2.Visible=true;
    不相同就执行一个错误信息!
      

  3.   

    using (SqlDataReader odr = cmd.ExecuteReader())
                        {
                            if (odr.Read())
                            {
                                return true;
                            }
                            return false;
                        }
      

  4.   

    private void login_ServerClick(object sender, System.EventArgs e)
    {
    if(IsUserIdentify())
    {
    Response.Redirect("index.aspx");
    }
    else
    {
    Response.Write("<script language=javascript>window.alert('请检查您所填写的用户名或密码是否正确!')</script>");
    }
    }
    private bool IsUserIdentify()
    {
    SqlConnection conn=DB.createConnection();
    conn.Open();
    string sql = "select * from reg where main_mail= '" + this.loginName.Value+ "' and password= '" + this.loginPwd.Value + "'";
    SqlCommand cmd = new SqlCommand(sql,conn);
    SqlDataReader reader = cmd.ExecuteReader();
    if(reader.Read())
    {
    Session["mail"]=this.loginName.Value;
    return true;
    }
    else
    {
    return false;
    }
    }
    }
      

  5.   

    知道,command有个ExecuteScalar()方法吗,他是返回你的查询结果的第一行第一列的
    你可以根据返回值是否为空判断!
      

  6.   

    大哥.怎么给分啊!我可以追加的!
    另外你上面给的代码SqlDataReader reader = cmd.ExecuteReader();出现语法错误!
    弄不明白!说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Data.SqlClient.SqlException: 在关键字 'user' 附近有语法错误。
      

  7.   

    SqldataAdpter da=new SqldataAdpter(("select * from user where username='"+txtusername.Text+"' and userpwd='"+txtuserpwd+"'",con);
    DataSet ds=new DataSet();
    da.fill(ds);
    if(ds.Tables[0].Rows.count>0)
    {
       RESPONSE.R...("*.ASPX");
    }
    else
     return ;