登陆代码(0)

            string password = txtPassword.Text.ToString();
            string name = txtUserName.SelectedItem.ToString();

            string connecitonString = "server=(local);" + "intetrated security=SSPI;" + "database=App";

            string mysql = "select 用户名 密码 from usertable";


            SqlConnection myConnection = new SqlConnection(connecitonString);
            myConnection.Open();
            SqlCommand cmd = new SqlCommand(mysql, myConnection);

            string Password = Convert.ToString(cmd.ExecuteScalar());
            if (Password == password)
            {
                frmMain a = new frmMain();
                a.ShowDialog();
            }
            else
            {
                MessageBox.Show("密码输入错误!");
            }
            myConnection.Close();
本博客有部分内容来自网络,如有问题请联系:hebeilijianghua@qq.com,并注明来自博客园。
原文地址:https://www.cnblogs.com/leebokeyuan/p/5586669.html