On Error GoTo Err
    
    Dim strAttributes As String, rdoMyEn As rdoEnvironment, r As Long
    
    If Index = 0 Then
        '登陆
        If Trim(Text1(0)) = "" Then
            MsgBox "请输入服务器名称!", vbOKOnly + vbExclamation, MsgHint
            Exit Sub
        End If
        
        Command1(0).Enabled = False
        Me.MousePointer = vbHourglass
        MyServer = TxtServer: MyUid = TxtName: MyPwd = TxtMm
        Set rdoMyEn = rdoEngine.rdoEnvironments(0)
        rdoMyEn.CursorDriver = rdUseClientBatch
        Set MyConnect = rdoMyEn.OpenConnection(dsName:="", Prompt:=rdDriverNoPrompt, Connect:="uid=" & Trim(Text1(1)) & _
                        ";pwd=" & Trim(Text1(2)) & ";driver={SQL Server};" & "Server=" & Trim(Text1(0)) & ";Database=Master;")
        MyConnect.QueryTimeout = 60
     
        MySql = "Exec Sp_Configure 'Allow Update',1"
        MyConnect.Execute MySql
     
        Me.MousePointer = vbDefault
        MsgBox "登录成功!", vbOKOnly + vbExclamation, MsgHint
        
        WritePrivateProfileString "Connect", "SvrName", Text1(0).Text, App.Path & "\ShOffice.ini"
        WritePrivateProfileString "Connect", "Supervisor", Text1(1).Text, App.Path & "\ShOffice.ini"
        WritePrivateProfileString "Connect", "Pwd", funPassword(Text1(2).Text, 7) & " ", App.Path & "\ShOffice.ini"
        Command1(1).Enabled = True
    Else
        '注册
        Command1(1).Enabled = False
        If RegDataBase = True Then
            MyConnect.Close
            ConnectDataBase
            IsRegist = True
            Unload Me
        Else
            Command1(1).Enabled = True
        End If
    End If
    Exit Sub
    
Err:
    MsgBox "登录失败!", vbOKOnly + vbCritical, MsgError
    Text1(0).SetFocus
    Me.MousePointer = vbDefault
    Command1(0).Enabled = True