怎么删除DataGridView中的一行数据
时间:2011-12-10
来源:互联网
C# code
int index = 0;//dataGridView1中ID列的索引 string temp = string.Format("delete goods where ID={0}", dataGridView1[index, dataGridView1.SelectedCells[0].RowIndex].Value); dataGridView1.Rows.RemoveAt(dataGridView1.SelectedCells[0].RowIndex);
这样只能在显示时删除表面的,但是数据库里还是没删除该行数据啊
作者: xiaogediao 发布时间: 2011-12-10
作者: bdmh 发布时间: 2011-12-10
作者: aganqin 发布时间: 2011-12-10
sda.Update(ds, "course");
作者: happyfsyy 发布时间: 2011-12-10
C# code
private void button4_Click(object sender, EventArgs e) { mycon = new SqlConnection(constr); int index = 0;//dataGridView1中ID列的索引 string temp = string.Format("delete goods where ID={0}", dataGridView1[index, dataGridView1.SelectedCells[0].RowIndex].Value); dataGridView1.Rows.RemoveAt(dataGridView1.SelectedCells[0].RowIndex); SqlDataAdapter da = new SqlDataAdapter("delete goods where id={0}", mycon); DataSet ds = new DataSet(); da.Fill(ds); SqlCommandBuilder scb = new SqlCommandBuilder(da); da.Update(ds, "course"); }
但是还是有异常 “0”附近有错误!
作者: xiaogediao 发布时间: 2011-12-10
作者: Xia5523 发布时间: 2011-12-10
你只是写了一个delete语句,却没有提交执行
作者: keenweiwei 发布时间: 2011-12-10
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28