0

This function is supposed to add a new defect on HPQC. However it gives an "Value does not fall within the expected range" when null is in the .addItem(). Does anyone know what might be the problem?

public static void addBug()
{
            String qcUrl = "LINK TO HPQC";
            String qcDomain = "DOMAIN";
            String qcProject = "PROJECT";
            String qcLoginName = "NAME";
            String qcPassword = "PASS";

            TDConnection connection = new TDConnection();
            connection.InitConnectionEx(qcUrl);
            connection.ConnectProjectEx(qcDomain, qcProject, qcLoginName, qcPassword);

            BugFactory bugFactory = connection.BugFactory;
            Bug bug = bugFactory.AddItem(null);

            bug.Status = "New";
            bug.Project = "QCIntegration";
            bug.Summary = "Short description of the bug";
            bug.DetectedBy = "Aaron Evans";
            bug.AssignedTo = "Nobody";
            bug.Priority = "Low";
            bug.Post();
}
Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
Kuews
  • 21
  • 1
  • 8
  • Why would you add null to something? That's like opening a closet to put nothing in... – Jeroen1984 Jul 31 '13 at 14:09
  • 1
    Something about BugFactory does not like the `null` you are adding. Not knowing how type `Bug` or `BugFactory` work, did you try `Bug bug = new Bug()` then adding it? – tyh Jul 31 '13 at 14:09
  • @Jeroen1984 , I dont know what else to add in it. Int, string, or keeping it empty is not working. – Kuews Jul 31 '13 at 14:14
  • @TYH , I just tried this, and I get a nasty error message. – Kuews Jul 31 '13 at 14:14
  • Try to pass in System.DBNull.Value and see what happens – Jeroen1984 Jul 31 '13 at 14:21
  • What is the expected parameter type of the method `bugFactory.AddItem(null)`? You are supplying `null`, which it clearly will not accept, but what does it _want_? A `String`...use `String.Empty`. Or what, then...? – DonBoitnott Jul 31 '13 at 14:45
  • What line throws the error? Are you _sure_ it's the `AddItem()` line? – DonBoitnott Jul 31 '13 at 14:48
  • I think its something with the values that are set for the BUG. I see the same code [here](https://github.com/fijiaaron/QCIntegration/blob/master/QCIntegration/Examples/CreateDefect.cs) – Nilesh Jul 31 '13 at 15:03
  • @Jeroen1984 , I think you solved the problem! Thanks! – Kuews Jul 31 '13 at 15:20

0 Answers0