09
2023
03
16:09:25

vb6.0中连接Access 数据库 实现读取和存储

Option Explicit

Private Sub Command1_Click()
Adodc1.Recordset.Fields("姓名") = Trim(Text1.Text)
Adodc1.Recordset.Fields("学号") = Trim(Text2.Text)
Adodc1.Recordset.Fields("电话") = Trim(Text3.Text)
Adodc1.Recordset.Fields("地址") = Trim(Text4.Text)
Adodc1.Recordset.Update
End Sub

Private Sub Command2_Click()
Dim YN As Integer
YN = MsgBox("确定删除?", vbYesNo)
If YN = 6 Then Adodc1.Recordset.Delete
End Sub

Private Sub Command3_Click()
Adodc1.Recordset.Fields("姓名") = Trim(Text1.Text)
Adodc1.Recordset.Fields("学号") = Trim(Text2.Text)
Adodc1.Recordset.Fields("电话") = Trim(Text3.Text)
Adodc1.Recordset.Fields("地址") = Trim(Text4.Text)
End Sub

Private Sub Command4_Click()
Adodc1.Recordset.CancelUpdate
Adodc1.Refresh
End Sub

Private Sub Command5_Click()
End
End Sub

Private Sub Command6_Click()
Adodc1.Recordset.AddNew
End Sub

Private Sub Command7_Click()
Adodc1.Recordset.Find Combo1.Text & "= '" & Trim(Text5) & "'", , , 1
If Adodc1.Recordset.EOF Then MsgBox "查找不到!!", , "提示"
End Sub

Private Sub Form_Load()
Dim constr As String
constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\data.mdb" & ";Persist Security Info=False"
Adodc1.ConnectionString = constr
Adodc1.CommandType = adCmdUnknown
Adodc1.RecordSource = "select * from 通讯录"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
End Sub



推荐本站淘宝优惠价购买喜欢的宝贝:

image.png

本文链接:https://hqyman.cn/post/3717.html 非本站原创文章欢迎转载,原创文章需保留本站地址!

分享到:
打赏





休息一下~~


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

请先 登录 再评论,若不是会员请先 注册

您的IP地址是: