zoukankan      html  css  js  c++  java
  • C# 登录界面从数据库取用户名密码匹配结束后进入登录界面

    private void button9_Click(object sender, EventArgs e)
            {
                string constr = "server=XB-20160802BVHL;database=Level_2;uid=sa;pwd=wly561561";//连接字符串里包含了数据库信息
                SqlConnection cnn = new SqlConnection(constr);//创建数据库连接
                cnn.Open();//打开连接
               
                string sql = "select * from 用户信息 where 用户名='" + textBox1.Text + "' and 密码 ='" + textBox2.Text + "'";
                SqlCommand cmd = new SqlCommand();  //SqlCommand表示对数据库要执行的操作命令。
                SqlDataAdapter da = new SqlDataAdapter(sql,cnn);
                DataSet ds = new DataSet();
                da.Fill(ds,"用户信息");
                DataTable dt = new DataTable();
                if (ds.Tables[0].Rows.Count > 0)
                {
                    this.Hide();
                }
                else 
                {
                    MessageBox.Show("用户名或者密码错误!");
                    textBox1.Text = "";
                    textBox2.Text = "";
                }
            }       
     
            private void button10_Click(object sender, EventArgs e)
            {
                Application.Exit();
            }
  • 相关阅读:
    iOS 11 application 新特性
    Swift循环遍历集合方法
    Swift 使用 #warning
    swift 3.0 正则表达式查找/替换字符
    App Store 审核指南
    iOS 获取设备的各种信息的方法
    闭包(Closure)
    Swift的Guard语句
    Swift 学习指引
    Swift 4.0 废弃的柯里化
  • 原文地址:https://www.cnblogs.com/topmount/p/8463593.html
Copyright © 2011-2022 走看看