📄 frm_login.frm
字号:
VERSION 5.00
Begin VB.Form Frm_Login
BorderStyle = 3 'Fixed Dialog
Caption = "登录数据库服务器"
ClientHeight = 1575
ClientLeft = 45
ClientTop = 330
ClientWidth = 4965
Icon = "Frm_Login.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1575
ScaleWidth = 4965
StartUpPosition = 2 '屏幕中心
Tag = "登录数据库服务器"
Begin VB.CommandButton CmdCancel
Cancel = -1 'True
Caption = "取 消(&C)"
Height = 435
Left = 3510
TabIndex = 7
Top = 780
Width = 1185
End
Begin VB.CommandButton CmdLogin
Caption = "登 录(&L)"
Default = -1 'True
Height = 435
Left = 3510
TabIndex = 6
Top = 240
Width = 1185
End
Begin VB.TextBox TxtUserName
Height = 315
IMEMode = 3 'DISABLE
Left = 1290
TabIndex = 5
Text = "sa"
ToolTipText = "登录到服务器的有效用户名"
Top = 570
Width = 1905
End
Begin VB.TextBox TxtUserPwd
Height = 315
IMEMode = 3 'DISABLE
Left = 1290
PasswordChar = "*"
TabIndex = 3
ToolTipText = "登录到服务器的有效用口令"
Top = 1020
Width = 1905
End
Begin VB.TextBox TxtSvrName
Height = 315
Left = 1290
TabIndex = 1
Top = 120
Width = 1905
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = " 用户名:"
Height = 180
Left = 420
TabIndex = 4
Top = 630
Width = 810
End
Begin VB.Label Label3
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "用户口令:"
Height = 180
Left = 330
TabIndex = 2
Top = 1080
Width = 900
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "服务器名:"
Height = 180
Left = 330
TabIndex = 0
Top = 180
Width = 900
End
End
Attribute VB_Name = "Frm_Login"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub CmdCancel_Click()
Unload Me
End Sub
Private Sub CmdLogin_Click()
Call Login
End Sub
Private Sub Form_Load()
Logined = False
TxtSvrName.Text = Trim(SvrName)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set Frm_Login = Nothing
End Sub
Public Sub Login()
Dim ErrStr As String
On Error GoTo Er
SvrName = Trim(TxtSvrName.Text)
CurUser = Trim(TxtUserName.Text)
CurPwd = Trim(TxtUserPwd.Text)
If SvrName = "" Then
MsgBox "请指定数据库服务器名!", vbExclamation, Me.Caption
TxtSvrName.SetFocus
Exit Sub
End If
If CurUser = "" Then
MsgBox "请指定登录到服务器的有效用户名!", vbExclamation, Me.Caption
TxtUserName.SetFocus
Exit Sub
End If
Me.MousePointer = vbHourglass
CmdLogin.Enabled = False
Cn.ConnectionString = CreateCnStr(CurUser, CurPwd, SvrName, "Master")
ErrStr = "登录服务器"
Me.Caption = "正在登录数据库服务器 " & SvrName & "..."
Cn.Open
Me.Caption = "登录服务器 " & SvrName & " 成功,开始初始化服务器..."
ErrStr = "初始化服务器"
' Call InitLogin
' If CheckInit Then Call InitServer
Me.MousePointer = vbDefault
Logined = True
Call CmdCancel_Click
Exit Sub
Er:
Me.MousePointer = vbDefault
Me.Caption = Me.Tag
MsgBox "错误:" & Err.Number & " 来自:" & Err.Source & vbCrLf & " 详细:" & Err.Description, vbExclamation, ErrStr & "错误:" & Err.Number
CmdLogin.Enabled = True
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -