⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmlogin.frm

📁 微软msde
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmLogin 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "msde 查询分析器连接"
   ClientHeight    =   4275
   ClientLeft      =   5970
   ClientTop       =   4425
   ClientWidth     =   5520
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4275
   ScaleWidth      =   5520
   ShowInTaskbar   =   0   'False
   Tag             =   "登录"
   Begin VB.TextBox txtUserName 
      Enabled         =   0   'False
      Height          =   270
      Left            =   2280
      TabIndex        =   3
      Top             =   2580
      Width           =   2565
   End
   Begin VB.TextBox txtPassword 
      Enabled         =   0   'False
      Height          =   270
      IMEMode         =   3  'DISABLE
      Left            =   2280
      PasswordChar    =   "*"
      TabIndex        =   4
      Top             =   2940
      Width           =   2565
   End
   Begin VB.CommandButton cmdOK 
      Caption         =   "确定"
      Default         =   -1  'True
      Height          =   360
      Left            =   1440
      TabIndex        =   5
      Tag             =   "确定"
      Top             =   3480
      Width           =   1140
   End
   Begin VB.CommandButton cmdCancel 
      Cancel          =   -1  'True
      Caption         =   "取消"
      Height          =   360
      Left            =   3000
      TabIndex        =   6
      Tag             =   "取消"
      Top             =   3480
      Width           =   1140
   End
   Begin VB.Frame Frame1 
      Caption         =   "connect by:"
      Height          =   975
      Left            =   360
      TabIndex        =   7
      Top             =   1200
      Width           =   3015
      Begin VB.OptionButton Option1 
         Caption         =   "Windows Authentication"
         Height          =   180
         Left            =   240
         TabIndex        =   1
         Top             =   240
         Value           =   -1  'True
         Width           =   2415
      End
      Begin VB.OptionButton Option2 
         Caption         =   "SQL Sever Authentication"
         Height          =   255
         Left            =   240
         TabIndex        =   2
         Top             =   600
         Width           =   2535
      End
   End
   Begin VB.TextBox Text1 
      Height          =   375
      Left            =   2400
      TabIndex        =   0
      Top             =   480
      Width           =   1935
   End
   Begin VB.Label lblLabels 
      Caption         =   "log name (&U):"
      Enabled         =   0   'False
      Height          =   255
      Index           =   0
      Left            =   720
      TabIndex        =   10
      Tag             =   "用户名(&U):"
      Top             =   2580
      Width           =   1305
   End
   Begin VB.Label lblLabels 
      Caption         =   "password(&P):"
      Enabled         =   0   'False
      Height          =   255
      Index           =   1
      Left            =   720
      TabIndex        =   9
      Tag             =   "密码(&P):"
      Top             =   2940
      Width           =   1320
   End
   Begin VB.Label Label1 
      Caption         =   "SQL Sever(s):"
      Height          =   255
      Left            =   840
      TabIndex        =   8
      Top             =   600
      Width           =   1575
   End
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long


Public OK As Boolean
Private Sub Form_Load()
    Dim sBuffer As String
    Dim lSize As Long
'登陆界面初始化
    sBuffer = Space$(255)
    lSize = Len(sBuffer)
    Call GetUserName(sBuffer, lSize)
    If lSize > 0 Then
        txtUserName.Text = Left$(sBuffer, lSize)
    Else
        txtUserName.Text = vbNullString
    End If
End Sub


Private Sub cmdCancel_Click()
    OK = False
    Me.Hide
End Sub


Private Sub cmdOK_Click()
    'ToDo: 创建测试密码是否正确
    '检查正确密码
    Me.MousePointer = 11 '改变鼠标样子
    username = txtUserName.Text
    computername = text1.Text
    If Option1.Value = True Then
        public_str_AdoPath = "PROVIDER=MSDASQL;Driver=SQL Server;Server=" + text1.Text + ";Database=master;"
    Else
        public_str_AdoPath = "PROVIDER=MSDASQL;Driver=SQL Server;Server=" + text1.Text + ";UID=" + txtUserName.Text + ";PWD=" + txtPassword.Text + ";Database=master;"
    End If
    
    On Error GoTo err
        Set adoconn = New ADODB.Connection
        adoconn.ConnectionTimeout = 5
        adoconn.Open (public_str_AdoPath)
    '***************************************
        OK = True
        Me.Hide
        If fMainForm Is Nothing Then
        Else
            fMainForm.LoadNewDoc
            fMainForm.Combo1.Text = "master"
        End If
        Me.MousePointer = 0 '改变鼠标样子
        Exit Sub
err:
    MsgBox (err.Description) '在msgbox中返回连接错误信息
    txtPassword.SelStart = 0
    txtPassword.SelLength = Len(txtPassword.Text)
    Me.MousePointer = 0 '改变鼠标样子
End Sub
'windows身份验证时:
Private Sub Option1_Click()
lblLabels(0).Enabled = False
lblLabels(1).Enabled = False
txtUserName.Enabled = False
txtPassword.Enabled = False
End Sub
'sql sever身份验证时:
Private Sub Option2_Click()
lblLabels(0).Enabled = True
lblLabels(1).Enabled = True
txtUserName.Enabled = True
txtPassword.Enabled = True
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -