注册 登录
编程论坛 C# 论坛

将datagridview1内容更新到sql数据库

gowine 发布于 2017-05-22 22:17, 2485 次点击
请问如何将datagridview1的内容更新到sql数据库,更新后清除内容. 在线等......急.......
1 回复
#2
樊明亮2017-06-17 23:02
回复 楼主 gowine
主要是用      dataGridView1.CurrentRow.Cells[0].Value获取值
    if (dataGridView1.CurrentRow.Cells[0].Value.ToString() == "Administrator")
            {
                MessageBox.Show("不能删除系统管理员");
                return;
            }
            string sql =string.Format(@"delete from loginInfo where 用户名 = '{0}'",dataGridView1.CurrentRow.Cells[0].Value.ToString());
            db.OperateData(sql);
            db.BindDataGridView(dataGridView1, "select 用户名,密码 from loginInfo");
1