Private Sub Winsock1_Connect()
If Winsock1.State = 7 Then
Winsock1.Close
End If
If m_linkflag = True Then
m_linkflag = False
MsgBox "已连接成功!"
End If
End Sub
Private Sub Winsock1_Error(ByVal Number As Integer, Description As String, ByVal Scode As Long, ByVal Source As String, ByVal HelpFile As String, ByVal HelpContext As Long, CancelDisplay As Boolean)
If Winsock1.State = 9 Then
Winsock1.Close
End If
Timer3.Enabled = False
MsgBox "与数据库的连接已断开!"
On Error GoTo lb_Err
Set iSQLServer = New SQLDMO.SQLServer
With iSQLServer
.LoginTimeout = 1
If sUser = "" Then
.LoginSecure = True
.Connect sServerName
Else
.Connect sServerName, sUser, sPassword
End If
Select Case .Status
Case SQLDMOSvc_Continuing
iRe = "正在连接"
Case SQLDMOSvc_Paused
iRe = "暂停"
Case SQLDMOSvc_Pausing
iRe = "正在暂停"
Case SQLDMOSvc_Running
iRe = "运行"
Case SQLDMOSvc_Starting
iRe = "正在启动"
Case SQLDMOSvc_Stopped
iRe = "停止"
Case SQLDMOSvc_Stopping
iRe = "正在停止"
Case SQLDMOSvc_Unknown
iRe = "未知"
End Select
.Disconnect
End With
GoTo lb_Exit
lb_Err:
MsgBox "错误:" & Error, 48
iRe = "错误"
lb_Exit:
If Not (iSQLServer Is Nothing) Then Set iSQLServer = Nothing
f_Get_ServerStatus = iRe
End Function