zoukankan      html  css  js  c++  java
  • ACCESS修改密码,更新显示

      public partial class 修改用户信息frm : Form
        {
            public 修改用户信息frm()
            {
                InitializeComponent();
            }
            
            public string username = "";
            public string newpaw ="";//密码
            public string newpawagi ="";//确认密码
            public  string myconnstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=ErLake.mdb";
    
            private void 修改用户信息frm_Load(object sender, EventArgs e)
            {
    
                loadtable();
     
            }
            public void loadtable()
            {
                DataTable mytableall = new DataTable();
                string mysqlall = "select * from tb_admin";
                OleDbDataAdapter da = new OleDbDataAdapter(mysqlall, myconnstring);
                da.Fill(mytableall);
                dataGridView1.DataSource = mytableall;
            }
      
            //添加选择行改变时,获取行号处理
    
            private void dataGridView1_SelectionChanged(object sender, EventArgs e)
            {
                this.dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
                if (this.dataGridView1.SelectionMode!=DataGridViewSelectionMode.FullColumnSelect)
                {
                    int rowindex = dataGridView1.CurrentRow.Index;//获取选中的行号
                    textBox1.Text = dataGridView1.Rows[rowindex].Cells[0].Value.ToString();
                    //textBox2.Text = dataGridView1.Rows[rowindex].Cells[1].Value.ToString();
                    //textBox3.Text = dataGridView1.Rows[rowindex].Cells[2].Value.ToString();
                    textBox2.Focus();//
    
                    
    
                }
            }
    
            private void 修改_Click(object sender, EventArgs e)
            {
    
                username=textBox1.Text;//用户名
                newpaw = textBox2.Text;//获取密码
                newpawagi = textBox3.Text;//获取密码
                if (newpaw != newpawagi)
                {
                    MessageBox.Show("两次密码不一致!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                }
                else
                {
                    string sqlcmd = "update tb_admin set 密码 = '"+newpaw+"' where 用户名='"+username+"'";//更新
                    OleDbConnection myconn = new OleDbConnection(myconnstring);
                    myconn.Open();
                    OleDbCommand mycomm = new OleDbCommand(sqlcmd,myconn);
                    mycomm.ExecuteNonQuery();
                    MessageBox.Show("密码修改成功!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                    loadtable();//加载表
                }
                
            }
    
            private void button2_Click(object sender, EventArgs e)
            {
                this.Close();
            }
        }
  • 相关阅读:
    001 spring AOP介绍
    026 spring事件机制--基础内容
    025 使用@Profile完成环境条件注入
    ExpandoObject使用
    企业微信接口问题
    企业号验证后携带URL参数跳转问题
    在创建一个MVC控制器,显示运行所选代码生成器时出错(带读写,使用EF)
    码栈批量提取淘宝后台的图图片空间图片
    码栈编码
    在微信里面打开链接,显示501 Not Implemented,但是同样的链接在其他浏览器是可以打开的。
  • 原文地址:https://www.cnblogs.com/yuhuameng/p/3668560.html
Copyright © 2011-2022 走看看