新年快乐!
一般介绍数据库的书都会有这种单方面的资料,根据自己的意愿将别人的成果组合就是你的软件了。
我曾用的登录、修改密码和盘托出如下:
Private Sub Command1_Click()
Dim s As String
s = App.Path & "\情况表.mdb"
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source =" + Chr(34) + s + Chr(34) & ";Jet OLEDB:Database Password=chen233;" '打开有密码数据库,密码为“chen233”
Dim SQL As String
SQL = "SELECT * FROM 权限表 where 姓名 = " & Chr(34) + Trim$(Text1(0).Text) + Chr(34)
= adCmdunknow 'SQL必须用此句,否则会显示FROM子句出错
Adodc1.RecordSource = SQL
Adodc1.Refresh
If Text1(1).Text = Adodc1.Recordset("密码") Then '密码正确则修改密码
If Text1(2).Text = Text1(3).Text And Text1(2).Text <> "" Then
Adodc1.Recordset("密码") = Text1(2).Text
Adodc1.Recordset.Update '更改密码成功
Unload Me
MDIForm_总.one.Enabled = True '根据权限进入不同的窗口
MDIForm_总.two.Enabled = True
Else
MsgBox "你二次的密码不一致,请重新输入!"
Text1(2).Text = ""
Text1(3).Text = ""
Text1(2).SetFocus
End If
End If
End Sub
Private Sub Command2_Click()
Call Incom '判断登录的有效性
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Activate()
Dim s As String
s = App.Path & "\情况表.mdb"
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source =" + Chr(34) + s + Chr(34) & ";Jet OLEDB:Database Password=chen233;" '打开有密码数据库,密码为“chen233”
'"Data Source =" + Chr(34) + s + Chr(34) & ";Persist Security Info=False" '打开无密码数据库
Dim SQL As String
SQL = "SELECT * FROM 权限表 "
= adCmdunknow 'SQL必须用此句,否则会显示FROM子句出错
Adodc1.RecordSource = SQL
Adodc1.Refresh
Text1(0).SetFocus
End Sub
Private Sub Form_Load()
Form_进入.Width = 5000
Form_进入.Height = 4500
Form_进入.Left = (Screen.Width - Form_进入.Width) / 2
Form_进入.Top = (Screen.Height - Form_进入.Height) / 4
Text1(1).PasswordChar = "*" '输入密码时显示*号
Text1(2).PasswordChar = "*"
Text1(3).PasswordChar = "*"
'Label2.Enabled = False
Adodc1.Visible = False
End Sub
Public Sub Incom() '登录判断
Static n As Integer '静态变量用于统计登录次数
Dim s As String
s = App.Path & "\情况表.mdb"
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source =" + Chr(34) + s + Chr(34) & ";Jet OLEDB:Database Password=chen233;" '打开有密码数据库,密码为“chen233”
Dim SQL As String, Purview$
SQL = "SELECT * FROM 权限表 where 姓名 = " & Chr(34) + Trim$(Text1(0).Text) + Chr(34)
= adCmdunknow 'SQL必须用此句,否则会显示FROM子句出错
Adodc1.RecordSource = SQL
Adodc1.Refresh
Purview = Adodc1.Recordset("权限")
If Trim$(Text1(0).Text) = Adodc1.Recordset("姓名") And Text1(1).Text = Adodc1.Recordset("密码") Then
Unload Me
If Purview = "输入" Then
MDIForm_总.one.Enabled = True '根据权限进入不同的菜单
MDIForm_总.two.Enabled = True
End If
If Purview = "查询" Then MDIForm_总.two.Enabled = True
Else
n = n + 1
If n < 3 Then
i = MsgBox("密码错误,请重新输入!", vbCritical + vbRetryCancel + vbDefaultButton1, "登录失败")
If i = vbRetry Then
Text1(1).Text = ""
Text1(1).SetFocus
Else
End
End If
Else
End
End If
End If
End Sub
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If Index = 0 And KeyAscii = 13 Then Text1(1).SetFocus
If Index = 1 And KeyAscii = 13 Then Command2.SetFocus
End Sub
以上是登录页面的全部信息
以下是录入的基本语句
With Adodc1
.Recordset("master") = Trim$(Text1(0).Text)
.Recordset("出生日期") = Text1(1).Text
.Recordset("参加工作时间") = Text1(2).Text
.Recordset("身份证号") = Trim$(Text1(3).Text)
.Recordset("学历") = Trim$(Combo1.Text)
End With
框架已成,加减即可成软件