zoukankan      html  css  js  c++  java
  • 登陆代码(1)

    SqlConnection conn = new SqlConnection("uid=sa;pwd=*;database=login;server=server"); 
       SqlCommand myCom = conn.CreateCommand(); 
       myCom.CommandType = CommandType.Text; 
    
       if(txtB_user.Text.Length == 0) 
       { 
        MessageBox.Show("用户不能为空,请查询后输入"); 
     
        return; 
       } 
    
       myCom.CommandText = "SELECT COUNT(*) FROM login WHERE username='"+txtB_user.Text+"'"; 
    
       conn.Open(); 
    
       if((int)myCom.ExecuteScalar() == 0) 
       { 
        MessageBox.Show("不存在此用户,请检查后重新输入","错误信息",MessageBoxButtons.OK,MessageBoxIcon.Error ); 
    
        return; 
       } 
       myCom.CommandText = "SELECT username,pass FROM login WHERE username='"+txtB_user.Text+"'"; 
    
       SqlDataReader myReader = myCom.ExecuteReader(); 
    
       if(myReader.Read()) 
       { 
        if(txtB_pass.Text == myReader[1].ToString() && txtB_user.Text.Length != 0) 
        { 
         MessageBox.Show("登录成功","恭喜",MessageBoxButtons.OK,MessageBoxIcon.Information); 
                        Form2 frm2 =new Form2();
         frm2.Show();
      
        } 
        else 
        { 
         MessageBox.Show("用户" + txtB_user.Text + "的密码不正确","提示信息",MessageBoxButtons.OK,MessageBoxIcon.Warning); 
         txtB_pass.Focus(); 
         return; 
        } 
       }  
    本博客有部分内容来自网络,如有问题请联系:hebeilijianghua@qq.com,并注明来自博客园。
  • 相关阅读:
    jdk和dubbo的SPI机制
    何谓架构
    ElasticSearch的API使用
    LFU的基本原理与实现
    如何判断单向链表有环?
    mysql执行过程以及顺序
    原来 TinyPNG 可以这样玩!
    deno + mongodb 实战踩坑记
    好消息,vue3.0 进入 beta 阶段!
    听说会做这道题的人后来都进了头条?
  • 原文地址:https://www.cnblogs.com/leebokeyuan/p/5586680.html
Copyright © 2011-2022 走看看