VBACCESS数据库的修改、删除、添加
Private Sub Command1_Click()
Dim s As String
Dim Conn As New ADODB.Connection
Dim Rs As New ADODB.Recordset
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\mydb.mdb"
请将数据库名及路径换成你的实际数据库名及路径
Dim UserName As String
Dim Password As String
s = Text1.Text
If s = "1" Or s = "2" Then
UserName = InputBox("请输入用户名")
Password = InputBox("请输入用户密码")
sql = "Select * From [UserInfo] where User=\" & UserName & "\"
UserInfo请换成你的实际数据表名
Rs.Open sql, Conn, 1, 3
If Rs.EOF Then
MsgBox "没有找到此用户"
Else
If Rs("Password") = Password Then
If s = "1" Then
MsgBox "123"
ElseIf s = "2" Then
MsgBox "456"
End If
Else
MsgBox "密码错误"
End If
End If
End If
End Sub
上面的例子实现了查询
如果是要添加,删除,更新等操作,只要编写相应的SQL语句,再用
Conn.Execute SQL 就可以了,如:
添加的:
SQL="Insert Into [UserInfo](User,Password
如果觉得《VB ACCESS数据库的修改 删除 添加》对你有帮助,请点赞、收藏,并留下你的观点哦!