📄 datalogin.frm
字号:
VERSION 5.00
Begin VB.Form DataLogin
BorderStyle = 3 'Fixed Dialog
Caption = "连接数据库"
ClientHeight = 3240
ClientLeft = 45
ClientTop = 330
ClientWidth = 5250
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3240
ScaleWidth = 5250
ShowInTaskbar = 0 'False
StartUpPosition = 2 'CenterScreen
Begin VB.Frame Frame1
Height = 3135
Left = 120
TabIndex = 0
Top = 0
Width = 4935
Begin VB.TextBox DbServer
Height = 375
Left = 1920
TabIndex = 6
Text = "127.0.0.1"
Top = 240
Width = 2415
End
Begin VB.TextBox DbName
Height = 375
Left = 1920
TabIndex = 5
Text = "touch"
Top = 840
Width = 2415
End
Begin VB.TextBox DbUser
Height = 375
Left = 1920
TabIndex = 4
Text = "sa"
Top = 1440
Width = 2415
End
Begin VB.TextBox DbPass
Height = 375
Left = 1920
TabIndex = 3
Top = 2040
Width = 2415
End
Begin VB.CommandButton Login
Caption = "登陆"
Default = -1 'True
Height = 375
Left = 960
TabIndex = 2
Top = 2640
Width = 1215
End
Begin VB.CommandButton Exit
Caption = "退出"
Height = 375
Left = 2640
TabIndex = 1
Top = 2640
Width = 1335
End
Begin VB.Label Label1
Caption = "数据库服务器名或IP:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 615
Left = 720
TabIndex = 10
Top = 240
Width = 975
End
Begin VB.Label Label2
Caption = "数据库名:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 840
TabIndex = 9
Top = 840
Width = 975
End
Begin VB.Label Label3
Caption = "用户名:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 960
TabIndex = 8
Top = 1440
Width = 975
End
Begin VB.Label Label4
Caption = "密码:"
BeginProperty Font
Name = "MS Sans Serif"
Size = 9.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1200
TabIndex = 7
Top = 2040
Width = 735
End
End
End
Attribute VB_Name = "DataLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Exit_Click()
End
End Sub
Private Sub Login_Click()
If DbServer.Text = "" Then
MsgBox "请输入数据库服务器名或IP", vbInformation, "系统提示"""
DbServer.SetFocus
Exit Sub
End If
If DbName.Text = "" Then
MsgBox "请输入数据库名", vbInformation, "系统提示"""
DbName.SetFocus
Exit Sub
End If
If DbUser.Text = "" Then
MsgBox "请输入用户名", vbInformation, "系统提示"""
DbUser.SetFocus
Exit Sub
End If
On Error GoTo err
conn.CursorLocation = adUseClient
conn.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=" & DbUser.Text & ";PWD=" & DbPass.Text & ";Initial Catalog=" & DbName.Text & ";Data Source=" & DbServer.Text & ""
err:
If conn.State = adStateOpen Then
DataMain.Show
Unload Me
Else
MsgBox "数据库连接出错", vbCritical, "提示信息"
Exit Sub
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -