连接QC/取消连接QC

来源:互联网 发布:ubuntu 16.04安装分区 编辑:程序博客网 时间:2024/05/18 00:54

'Connect to QC

'sURL: QC link

'sDomin: Domain

'sProject:Project

'sUser:UserName

'sPwd:Password


Function ConnectQC(sURL, sDomin, sProject, sUser, sPwd)
    ConnectQC = 0
    Set tdQC = CreateObject("TDApiOle80.TDConnection.1")
    On Error Resume Next
    tdQC.InitConnectionEx sURL
    If ERR.Number <> 0 Then
        ConnectQC = -1
        Exit Function
    End If
    On Error GoTo 0
   
    On Error Resume Next
    tdQC.Login sUser, sPwd

    If ERR.Number <> 0 Then
        ConnectQC = -1
        Exit Function
    End If
    On Error GoTo 0
   
    On Error Resume Next
    tdQC.Connect sDomin, sProject
    If ERR.Number <> 0 Then
        ConnectQC = -1
        Exit Function
    End If
    On Error GoTo 0
   
End Function

'Disconnect QC
Function DisconnectQC()
   tdQC.ReleaseConnection
End Function