C#登陆的代码

解决方案 »

  1.   

    http://topic.csdn.net/u/20100114/16/5087b9c2-4f0b-41ea-bbfb-74a517f57482.html有高手谁去帮我看看这个啊。。 很急的。
      

  2.   

    C#windows程序的用sql的数据库,实现登陆 像qq那样
      

  3.   

      string username = this.txtName.Text;//登陆用户名
           string password = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtPwd.Text, "MD5");//登陆密码,加密处理
          
            User u = UserManager.Login1(username, password);//调用业务逻辑层验证用户存在的方法
            if (u != null)
            {
                Session["UserName"] = username;
                Session["UserID"] = u.UserID;
                Session["Utype"] = u.UserType;
                string uid = u.UserID.ToString();
               
              Response.Redirect("Index.aspx");
      

  4.   

    思路大概是这样:
    用socket把用户名和加密后的密码传到服务端,在服务端验证后返回是否让这个用户跳转到主界面或者提示密码错误..
    至于代码这个还是要自己写,每个项目的需求都不一样
      

  5.   

    来个简单点的
    string LoginId=this.txtLoginId.text.tostring();//获得用户名
    string LoginPwd=this.txtLoginPwd.text.tostring();//获得密码string sql=string.format("select count(*) from user where name={0} and pwd={1}",LoginId,LoginPwd);string con="data source=.;initial catalog=数据库name;integrated security=sspi";//windows登录数据库sqlconnection conn=new sqlconnection(con);try
    {
       conn.open();
       sqlcommand cmd=new sqlcommand(sql,conn);
       int num=cmd.ExecuteNonQuery();
       if(num>0)
          {
            成功;
          }
       else
          {
            失败;
          }
    }
    catch
    {}
    finally 
    {
       conn.close();
    }