就是一般网站的登录和注册,怎么拿到字符串跟数据库里的具体内容进行比较呢?用什么控件?本人刚学,,很多不懂,,很纠结~

解决方案 »

  1.   

    你可以从数据库中查询出来 用equery比较
      

  2.   

    一般都是手写代码的SqlConnection conn=new SqlConnection("server=.;database=jijunwu;uid=sa;pwd=;");//字符串连接语句
    SqlCommand cmd=new SqlCommand("login",conn);//创建command对象
    cmd.CommandType=CommandType.StoredProcedure;//声明执行的是存储过程
    cmd.Parameters.Add("@name",this.TextBox1.Text.ToLower());//声明参数
    cmd.Parameters.Add("@pwd",System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.TextBox2.Text.ToLower(),"md5"));//给参数赋值
    conn.Open();//打开数据库连接
    int i=Convert.ToInt32(cmd.ExecuteScalar());//执行Sql语句返回首行首列
    if(i==1)//判断权限
    {
    Session["power"]=1;  //定义power
    Session["name"]=this.TextBox1.Text;//定义name

    System.Web.Security.FormsAuthentication.SetAuthCookie(this.TextBox1.Text,false);//设置cookies
    Response.Redirect("Admin/default.aspx");//页面跳转
    }

    if(i==2)
    {
    Session["power"]=2;
    Session["name"]=this.TextBox1.Text;
    System.Web.Security.FormsAuthentication.SetAuthCookie(this.TextBox1.Text,false);
    Response.Redirect("Admin/default.aspx");
    }
    CREATE PROCEDURE login
    (
    @name varchar(100),
    @pwd varchar(100))
    AS
    select usertype from jjw_admin where username=@name  and userpwd=@pwd
      

  3.   

    在VS中工具箱里有LOGIN 和REGISTER控件