vb.net 2008 删除数据库中的某一行

天若海愚 2012-12-19 01:26:30
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
Dim str As String
Dim ds As DataSet
str = DataGridView1.CurrentRow.Index
Dim i As MsgBoxResult = MsgBox("确定要删除该用户吗?", MsgBoxStyle.OkCancel, "警告")
If i = MsgBoxResult.Ok Then
Select ComboBox1.Text
Case "组立工程"
search.query("delete from T_Zuli where C_UserID = '" & str & "'")
MsgBox("已成功删除该用户!", MsgBoxStyle.OkOnly, "提示")
ds = search.query("select C_UserID,C_UserID,C_UserName from T_Zuli")
Case "照度测试"
search.query("delete from T_Zhaodu where C_UserID = '" & str & "'")
MsgBox("已成功删除该用户!", MsgBoxStyle.OkOnly, "提示")
ds = search.query("select C_UserID,C_UserID,C_UserName from T_Zhaodu")
Case "标签工位"
search.query("delete from T_Biaoqian where C_UserID = '" & str & "'")
MsgBox("已成功删除该用户!", MsgBoxStyle.OkOnly, "提示")
ds = search.query("select C_UserID,C_UserID,C_UserName from T_Biaoqian")
Case "包装工程"
search.query("delete from T_Baozhuang where C_UserID = '" & str & "'")
MsgBox("已成功删除该用户!", MsgBoxStyle.OkOnly, "提示")
ds = search.query("select C_UserID,C_UserID,C_UserName from T_Baozhuang")
Case "修理工位"
search.query("delete from T_Xiuli where C_UserID = '" & str & "'")
MsgBox("已成功删除该用户!", MsgBoxStyle.OkOnly, "提示")
ds = search.query("select C_UserID,C_UserID,C_UserName from T_Xiuli")
End Select
DataGridView1.DataSource = ds.Tables(0)
End If
If i = MsgBoxResult.Cancel Then
Exit Sub
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub


数据库是ACCESS2003的,但是我就是无法删除我选中的那一行数据,str = DataGridView1.CurrentRow.Index 是不是这一行有问题啊
...全文
247 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
良朋 2012-12-21
  • 打赏
  • 举报
回复
DataGridView1.CurrentCell.Value
良朋 2012-12-21
  • 打赏
  • 举报
回复
改为DataGridView1.CurrentRow.Cells(0).Value 注意Cells(0)的值
良朋 2012-12-21
  • 打赏
  • 举报
回复
是str = DataGridView1.CurrentRow.Index 这行有问题, 你监视一下就知道了。

16,557

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧