VS2005中的Login控件拖出来后不知道怎么用~~
我要让它验证数据库中的数据与输入的数据一样后才能登录,可不知道怎么这个控件怎么连到自己的数据库.
请高手指点~~

解决方案 »

  1.   

    我们做过管理系统的课程设计,关于登陆验证的这个是通过了的,希望有用private void button1_Click(object sender, EventArgs e)
            {
              if (txt1.Text == "")
                {
                    MessageBox.Show("请输入用户名", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (txt2.Text == "")
                    {
                        MessageBox.Show("请输入密码", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        SqlConnection cn = new SqlConnection(@"server=localhost; database=fantasy; uid=sa; pwd=sa");//连接数据库 
                        cn.Open();
                        string sql = "select count(*) from passID where [用户名]='" + txt1.Text + "' and [密码]='" + txt2.Text + "'";
                        SqlCommand cm = new SqlCommand(sql, cn);
                        int i = Convert.ToInt32(cm.ExecuteScalar());//将查询的结果返回一个值,如果有的话就说明用户名 密码正确 
                        if (i > 0)
                        {
                            cm = new SqlCommand("select * from passID where [用户名]='" + txt1.Text + "'", cn);//查询得到用户名的信息 
                            SqlDataReader sdr = cm.ExecuteReader();
                            sdr.Read();
                     
                            cn.Close();
                            frmMain main = new frmMain();
                         
                            main.ShowDialog();
                            
                            //Class1.fomload = false;
                            //Class1.fomload1 = false;
                            this.Close();
                        }
                        else
                        {
                            MessageBox.Show("用户名或密码错误!");
                        }
                    }
                }
            }
      

  2.   

    不是的,vs2005的Login控件是一个整体的东西,不是单独按了button按钮去获取TextBox里的数据,然后检查数据库里的数据是否存在。不知道Login控件怎么才能获取到数据库里的东西~