VB6.0删除指定ID记录
求助各位大师:怎样用VB6.0删除access数据库中ID号=text1的记录?数据库名称为:用户信息,表名为:用户表,字段和datagrid1显示的一样。
2020-07-10 15:39
2020-07-10 16:43
2020-07-10 17:27

2020-07-10 22:04
2020-07-11 08:00
程序代码:
Private Sub Command1_Click()
If Val(Text1.Text) < 1 Then
MsgBox "你没有输入需要删除的ID号,请填写!", 16, "无法删除!"
Exit Sub
End If
Dim cn As New ADODB.Connection, RS As New ADODB.Recordset
cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & App.Path & "\用户信息.accdb;Jet OLEDB:Database Password=;"
RS.Open "Select * From 用户表 where ID=" & Val(Text1.Text) & "", cn, 3, 2
RS.Delete '删除指定记录
RS.Close
cn.Close
MsgBox "数据表用户表中ID=" & Val(Text1.Text) & "的记录已经删除!", 64, "删除成功!"
End Sub
程序代码:
Private Sub Command2_Click()
If Val(Text1.Text) < 1 Then
MsgBox "你没有输入需要删除的ID号,请填写!", 16, "无法删除!"
Exit Sub
End If
Adodc1.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & App.Path & "\用户信息.accdb;Jet OLEDB:Database Password=;"
Adodc1.RecordSource = "Select * From 用户表 where ID=" & Val(Text1.Text) & ""
Adodc1.Recordset.Delete '删除指定记录
Adodc1.Recordset
MsgBox "数据表用户表中ID=" & Val(Text1.Text) & "的记录已经删除!", 64, "删除成功!"
End Sub
[此贴子已经被作者于2020-7-11 12:24编辑过]

2020-07-11 12:04
2020-07-11 16:32
2020-07-11 16:51