?? dlgserver_a.frm
字號:
VERSION 5.00
Object = "{0B81E4A9-BE4E-4AEF-9272-33AB5B51C6FC}#1.0#0"; "XPControls.ocx"
Begin VB.Form dlgServer_A
BorderStyle = 3 'Fixed Dialog
Caption = "數據庫連接屬性"
ClientHeight = 4545
ClientLeft = 45
ClientTop = 435
ClientWidth = 5520
Icon = "dlgServer_A.frx":0000
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4545
ScaleWidth = 5520
ShowInTaskbar = 0 'False
StartUpPosition = 3 'Windows Default
Begin VB.Frame Frame1
BackColor = &H80000018&
Caption = "服務器信息"
Height = 3525
Left = 180
TabIndex = 0
Top = 180
Width = 5145
Begin VB.ComboBox cmbServer
Height = 315
Left = 720
TabIndex = 5
Top = 990
Width = 3045
End
Begin VB.OptionButton optUseWinnt
BackColor = &H80000018&
Caption = "使用Windows NT集成安全驗證(&W)"
Height = 315
Left = 690
TabIndex = 4
Top = 1800
Value = -1 'True
Width = 3075
End
Begin VB.OptionButton optUseUser
BackColor = &H80000018&
Caption = "使用指定的用戶名稱和密碼(&U)"
Height = 315
Left = 690
TabIndex = 3
Top = 2280
Width = 3015
End
Begin VB.TextBox txtUser
Height = 285
Left = 1980
TabIndex = 2
Top = 2685
Width = 2505
End
Begin VB.TextBox txtPassword
BeginProperty Font
Name = "宋體"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
IMEMode = 3 'DISABLE
Left = 1980
PasswordChar = "*"
TabIndex = 1
Top = 3045
Width = 2505
End
Begin XPControls.XPCommandButton cmdRefresh
Height = 285
Left = 3870
TabIndex = 6
Top = 990
Width = 645
_ExtentX = 1138
_ExtentY = 503
Caption = "刷新"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.Label Label1
AutoSize = -1 'True
BackColor = &H80000018&
Caption = "指定下列設置以連接到SQL Server數據庫:"
Height = 195
Left = 300
TabIndex = 11
Top = 300
Width = 3345
End
Begin VB.Label Label2
AutoSize = -1 'True
BackColor = &H80000018&
Caption = "1. 選擇或輸入服務器名稱(&E):"
Height = 195
Left = 420
TabIndex = 10
Top = 690
Width = 2355
End
Begin VB.Label Label3
AutoSize = -1 'True
BackColor = &H80000018&
Caption = "2. 輸入登錄服務器的信息:"
Height = 195
Left = 420
TabIndex = 9
Top = 1440
Width = 2160
End
Begin VB.Label Label4
AutoSize = -1 'True
BackColor = &H80000018&
Caption = "用戶名稱:"
Height = 195
Left = 1020
TabIndex = 8
Top = 2730
Width = 900
End
Begin VB.Label Label5
AutoSize = -1 'True
BackColor = &H80000018&
Caption = "密碼:"
Height = 195
Left = 1020
TabIndex = 7
Top = 3090
Width = 540
End
End
Begin XPControls.XPCommandButton cmdCancel
Cancel = -1 'True
Height = 375
Left = 3210
TabIndex = 12
Top = 3900
Width = 975
_ExtentX = 1720
_ExtentY = 661
Caption = "取消(&C)"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin XPControls.XPCommandButton cmdOK
Height = 375
Left = 1620
TabIndex = 13
Top = 3900
Width = 975
_ExtentX = 1720
_ExtentY = 661
Caption = "確定(&O)"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
End
Attribute VB_Name = "dlgServer_A"
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 cmdOK_Click()
On Error GoTo ErrMsg
Dim Status
Dim strSQL As String
Dim strServer As String
Dim blnUseWinnt As Boolean
Dim strUser As String
Dim strPassword As String
Me.MousePointer = 11
'是否選擇了服務器
If cmbServer.Text = "" Then
MsgBox "請輸入或選擇服務器名稱!", vbInformation, "提示"
cmbServer.SetFocus
GoTo ExitLab
End If
strServer = cmbServer.Text
strSQL = "Provider=SQLOLEDB.1;Initial Catalog=master;Data Source=" & strServer
'選擇了哪一種驗證方式
If optUseWinnt.Value = True Then
'采取了windows混合驗證
strSQL = strSQL & ";Integrated Security=SSPI;Persist Security Info=False"
Else
'采取指定用戶名稱和密碼驗證
strSQL = strSQL & ";Persist Security Info=True;User ID=" & txtUser.Text _
& ";Password=" & txtPassword.Text
End If
On Error Resume Next
GCon.ConnectionString = strSQL
GCon.CursorLocation = adUseClient
GCon.Open
If Err.Number <> 0 Then
Err.Clear
MsgBox "無法連接指定的服務器!請確認是否有適當的權限,或者服務器正在運行!", vbCritical, "提示"
GoTo ExitLab
Else
If AppendDatabase = True Then
Me.MousePointer = 0
Unload Me
End If
End If
' '如果成功,則把配置信息寫入配置文件
' WriteINI gstrCurrPath & DSNINIFile, "Database", "Server", strServer
' If optUseWinnt.Value = True Then
' WriteINI gstrCurrPath & DSNINIFile, "Database", "UseWinnt", "True"
' Else
' WriteINI gstrCurrPath & DSNINIFile, "Database", "UseWinnt", "False"
' WriteINI gstrCurrPath & DSNINIFile, "Database", "UID", txtUser.Text
' WriteINI gstrCurrPath & DSNINIFile, "Database", "PWD", txtPassword.Text
' End If
GoTo ExitLab
ErrMsg:
Status = SetError(Err.Number, Err.Description, Err.Source)
ErrMsg Status
ExitLab:
Me.MousePointer = 0
End Sub
Private Sub cmdRefresh_Click()
GetLocalSQLServer cmbServer
End Sub
Private Sub Form_Load()
optUseWinnt_Click
End Sub
Private Sub optUseWinnt_Click()
txtUser.Enabled = False
txtPassword.Enabled = False
txtUser.BackColor = &H8000000F
txtPassword.BackColor = &H8000000F
End Sub
Private Sub optUseUser_Click()
txtUser.Enabled = True
txtPassword.Enabled = True
txtUser.BackColor = vbWhite
txtPassword.BackColor = vbWhite
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -