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();
            }
  • 相关阅读:
    vue3.0基本使用
    node 版本升级
    Steam游戏《Northgard(北境之地)》修改器制作
    万能WEB弹出框,js随意适配
    数据湖了解
    操作系统(一)
    无题
    基于林业害虫识别系统的缺陷分析
    美化Android下拉刷新
    软件测试
  • 原文地址:https://www.cnblogs.com/topmount/p/8463593.html
Copyright © 2011-2022 走看看