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();
            }
        }
  • 相关阅读:
    ACS 20070108 更新
    道德沦丧 还是意识淡薄
    Alienwave.CommunityServer 20070103 更新
    无题
    《白马啸西风》之李文秀
    突然感觉自己像拉皮条的
    数据库日志文件(x.ldf)如何打开?
    调试.NET出错
    老大离开南京了
    最近太任性了
  • 原文地址:https://www.cnblogs.com/yuhuameng/p/3668560.html
Copyright © 2011-2022 走看看