Private Sub MSHFGrid_Click()
MSHFGridRow = MSHFGridRowSel
End Sub
If MsgBox("你确定删除编号为:[" & MSHFGridText & "] ", vbQuestion + vbYesNo, "删除") = vbYes Then
Set ResDel = New ADODBRecordset
ResDelOpen "delete from UserInfo where UserId='" & MSHFGridText & "'", Conn, 1, 2
MsgBox "删除成功!", vbInformation, "成功"
If ResDelState <> 0 Then ResDelClose
ResDelOpen "select from viewUserInfo", Conn, 1, 1
Set MSHFGridDataSource = ResDel
If ResDelState <> 0 Then ResDelClose
Set ResDel = Nothing
End If
还有什么不懂的 可以再问我
用sql语句的删除命令:delete from (表名) where (条件)
举例如下:(最好系统学一下,因为不知道你用的什么方法进行vb *** 作)
(我为推荐一本书,电大的计算机大专计算机信息方向的《VB程序设计》刘世峰编,通学习你一切都通了)
Private Sub Command1_Click()
'定义字符
Dim strSQL As String
'定义一个整型变量
Dim i As Integer
i = MSHFlexGrid1Row
'处理无记录行
If MSHFlexGrid1TextMatrix(i, 1) = "" Then
MsgBox "请选择一个记录!", vbQuestion + vbOKOnly, "信息提示"
Exit Sub
End If
'编定SQ查询语句
strSQL = "Delete From 通讯簿 "
strSQL = strSQL + "Where 姓名='" + MSHFlexGrid1TextMatrix(i, 1) + "'"
'提示用户要谨慎删除
If MsgBox("是否要删除,请慎重!", vbQuestion + vbOKCancel, "信息提示") = vbOK Then
'执行删除命令
ADOcnExecute strSQL
End If
DisplayGrid1
End Sub
帮你改了看可以吗?
有2种写法:
‘第一种
Dim conn As New ADODBConnection
Dim rs As New ADODBRecordset
Dim Str1 As String
Dim Str2 As String
Dim Str3 As String
Str1 = "Provider=MicrosoftJetOLEDB40;"
Str2 = "Data Source=d:\db1mdb;"
Str3 = "Jet OLEDB:Database Password="
connOpen Str1 & Str2 & Str3
strsql = "select from jieyong"
rsOpen strsql, conn, 3, 3
For i = 0 To rsFieldsCount - 1
if text1text = rsfields(i) then
rsdelete
rsmovenext
rsclose
else
msgbox("无该记录!")
end if
next
‘第二种
Dim conn As New ADODBConnection
Dim rs As New ADODBRecordset
Dim strsql AS String
connConnectionString = "provider=MicrosoftjetOLEDB40;" & _
"Persist security info= False; Data Source=d:\db1mdb"
connOpen
strsql = "select from jieyong where 栏位名 = '%" & text1text & "%'"
rsOpen strsql, conn, 3, 3
If rsRecordCount <> 0 Then
rsdelete
rsmovenext
rsclose
else
msgbox("无该记录!")
end if
next
以上就是关于vb6.0中 DataGrid删除当前选定行数据全部的内容,包括:vb6.0中 DataGrid删除当前选定行数据、如何使用Delete语句从VB数据库删除信息、VB中如何实现删除数据库的记录等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)