vb中用代码删除当前datagrid当前记录?
代码如下:PrivateSubCommand3_Click()DimconnAsNewADODB.Connectionconn.ConnectionString="Pro...
代码如下:
Private Sub Command3_Click()
Dim conn As New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=win.mdb;Persist Security Info=False" '如果不用这个模块也行可以,这一句便是常用的引擎。
conn.Open
strsql = "delete from memoA where 医院名称 ='" & Text1.Text & "'"
If MsgBox("数据删除不可恢复,请确认!", vbInformation + vbYesNo, "友情提示") = vbYes Then
conn.Execute strsql
MsgBox "记录已经删除!"
Else
MsgBox "确认退出!", vbInformation, "退出"
End If
conn.Close
End Sub
我这个是先用text1文本查询这条记录之后在datagrid1里面显示的,然后我用语句删掉这条记录,我想直接查询出来后在datagrid1里面选中当前某条记录之后删除代码应该怎么改呢?
Private Sub Command6_Click()
Dim conn As New Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=win.mdb;Persist Security Info=False" '如果不用这个模块也行可以,这一句便是常用的引擎。
conn.Open
Dim rss As New Recordset
rs.Open "delete from memoA ", conn
With rss
.Delete
.MoveNext
If .EOF Then .MoveLast
End With
End Sub
请问这样写吗?
能不能帮忙改一改 展开
Private Sub Command3_Click()
Dim conn As New ADODB.Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=win.mdb;Persist Security Info=False" '如果不用这个模块也行可以,这一句便是常用的引擎。
conn.Open
strsql = "delete from memoA where 医院名称 ='" & Text1.Text & "'"
If MsgBox("数据删除不可恢复,请确认!", vbInformation + vbYesNo, "友情提示") = vbYes Then
conn.Execute strsql
MsgBox "记录已经删除!"
Else
MsgBox "确认退出!", vbInformation, "退出"
End If
conn.Close
End Sub
我这个是先用text1文本查询这条记录之后在datagrid1里面显示的,然后我用语句删掉这条记录,我想直接查询出来后在datagrid1里面选中当前某条记录之后删除代码应该怎么改呢?
Private Sub Command6_Click()
Dim conn As New Connection
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=win.mdb;Persist Security Info=False" '如果不用这个模块也行可以,这一句便是常用的引擎。
conn.Open
Dim rss As New Recordset
rs.Open "delete from memoA ", conn
With rss
.Delete
.MoveNext
If .EOF Then .MoveLast
End With
End Sub
请问这样写吗?
能不能帮忙改一改 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询