Tuesday, August 23, 2011

Visual Basic Program that uses the Quality Center API

How to create a Visual Basic program that uses the Quality Center API?

Description:
This example adds a defect to a project using Visual Basic 6.0.
Usage:
1. Open Microsoft Visual Basic 6.0.
2. From the menu, select File -> New Project, and choose Standard EXE.
3. From the menu, select Project -> References -> OTA COM 8.0 Type Library.
4. Click <OK>.
5. Double-click on the form.
6. Add the code below.

Code:
Private Sub Form_Load()
Dim td As New TDConnection
td.InitConnectionEx "http://<servername>/tdbin"
'Note: For Quality Center, connect by using the URL below:
'td.InitConnectionEx "http://<servername>:port/qcbin"
td.ConnectProjectEx "DomainName", "ProjectName", "UserName", "Password"

Dim bfact As BugFactory
Dim mybug As Bug
Set bfact = td.BugFactory
'Add defects
Set mybug = bfact.AddItem("Defect")
mybug.Summary = "Test"
mybug.Status = "Open"
mybug.Post

td.DisconnectProject()
td.ReleaseConnection()
MsgBox ("Added 1 new defect!")
Set mybug = Nothing
Set bfact = Nothing
Set td = Nothing
End Sub

No comments:

Post a Comment