帮忙做个页面
登录窗体:
Option Explicit
Dim pnum As Integer
Private Sub XPButton1_Click()
On Error GoTo finish '防错代码,防止意外而导致的退出
sql = "select * from 用户管理 where 用户名='" & Text1。 Text & "' and 密码='" & Text2。Text & "'"
cn。ConnectionString = "Provider=Microsoft。Jet。OLEDB。4。 0;Data Source=" & App。Path & "\data\ b;Persi...全部
登录窗体:
Option Explicit
Dim pnum As Integer
Private Sub XPButton1_Click()
On Error GoTo finish '防错代码,防止意外而导致的退出
sql = "select * from 用户管理 where 用户名='" & Text1。
Text & "' and 密码='" & Text2。Text & "'"
cn。ConnectionString = "Provider=Microsoft。Jet。OLEDB。4。
0;Data Source=" & App。Path & "\data\ b;Persist Security Info=False"
cn。Open
rs。CursorLocation = adUseClient
rs。
Open sql, cn, adOpenDynamic, adLockOptimistic
'以上使用最通用的方法来查询数据库中是否有匹配的记录
If rs。EOF = True Then '如果没有记录则说明用户或密码为错误的
If pnum "" Then
sql = "select * from 用户管理 where 用户名='" & Text1。
Text & "'" ' and 密码='" & Text2。Text & "'"
cn。ConnectionString = "Provider=Microsoft。Jet。
OLEDB。4。0;Data Source=" & App。Path & "\data\ b;Persist Security Info=False"
cn。Open
rs。
CursorLocation = adUseClient
rs。Open sql, cn, adOpenDynamic, adLockOptimistic
If rs。
EOF = True Then '没有该用户名可以注册
MsgBox "用户名可以注册!"
rs。Close
cn。
Close
Newname = Text1。Text
Text4 = Newname
Text2。
SetFocus
Else
MsgBox "该用户名已经存在,换名注册!"
Text1。Text = ""
Text1。
SetFocus
End If
End If
Exit Sub
finish:
MsgBox Err。Description
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And Text2 <> "" Then
Password = Text2。
Text
Text5 = Password
Text3。SetFocus
End If
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 And Text3。
Text = Text2。Text Then
XPButton3。Enabled = True
XPButton3。SetFocus
ElseIf KeyAscii = 13 And Text3。
Text <> Text2。Text Then
Text3 = ""
Text3。SetFocus
End If
End Sub
Private Sub XPButton1_Click()
Unload Me
End Sub
模块:
Option Explicit
Public loginname As String
Public cn As New ADODB。
Connection '定义数据库的连接存放数据和代码
Public rs As New ADODB。Recordset
Public sql As String
Public Newname As String
。
收起