📄 login.frm
字号:
VERSION 5.00
Begin VB.Form Login
Caption = "用户登录"
ClientHeight = 3990
ClientLeft = 5640
ClientTop = 2640
ClientWidth = 4665
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 3990
ScaleWidth = 4665
Tag = "Main"
Begin VB.CommandButton Command2
Cancel = -1 'True
Caption = "取消"
Height = 375
Left = 2400
TabIndex = 6
Top = 2640
Width = 1455
End
Begin VB.CommandButton Command1
Caption = "登录"
Default = -1 'True
Height = 375
Left = 600
TabIndex = 5
Top = 2640
Width = 1455
End
Begin VB.TextBox txtPwd
Height = 375
IMEMode = 3 'DISABLE
Left = 1800
PasswordChar = "*"
TabIndex = 4
Top = 1920
Width = 1335
End
Begin VB.TextBox txtUser
Height = 375
Left = 1800
TabIndex = 3
Top = 1320
Width = 1335
End
Begin VB.Label Label4
Caption = "版权所有(c)2007 华北水利水电学院信息工程学院"
Height = 375
Left = 360
TabIndex = 7
Top = 3480
Width = 4095
End
Begin VB.Label Label3
Caption = "密 码:"
Height = 255
Left = 960
TabIndex = 2
Top = 2040
Width = 855
End
Begin VB.Label Label2
Caption = "用户名:"
Height = 375
Left = 960
TabIndex = 1
Top = 1440
Width = 855
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "个人通讯录"
BeginProperty Font
Name = "华文彩云"
Size = 26.25
Charset = 134
Weight = 700
Underline = 0 'False
Italic = -1 'True
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 120
TabIndex = 0
Top = 360
Width = 4215
End
End
Attribute VB_Name = "Login"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim conn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL As String
Dim ConnString As String
Private Sub Command1_Click()
If txtUser.Text = "" Then
MsgBox "请输入用户名", vbOKOnly, "Login"
txtUser.SetFocus
ElseIf txtPwd.Text = "" Then
MsgBox "请输入密码", vbOKOnly, "Login"
txtPwd.SetFocus
Else
'链接数据库
conn.Open ConnString
strSQL = "select * from Users where User_Name='" + txtUser.Text + "'"
strSQL = strSQL + "and User_ID='" + txtPwd.Text + "'"
rs.Open strSQL, conn
If rs.EOF Then
MsgBox "用户名或密码错误!", vbOKOnly + vbExclamation, "Login"
txtUser.SetFocus
txtUser.SelStart = 0
txtUser.SelLength = Len(txtUser.Text)
Else
Session_Name = txtUser.Text
MsgBox "登录成功!", vbOKOnly + vbExclamation, "Login"
Unload Login
MainInfo.Show
End If
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
'ConnString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=BookManage"
ConnString = "Provider=SQLOLEDB.1;Persist Security Info=False;Data Source=.;Initial Catalog=txlxt;User ID=sa;Password="
Set conn = New ADODB.Connection
Set rs = New ADODB.Recordset
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -