0

I am new to ASP.net C#. I have an application to get inputs from users and save in database. I have followed the N-tier architecture in creating this app upon request. I have created an object in the codebehind and set the input values to them and pass the object to a method in the Business Layer and also called a method in Data Access Layer to the Business Layer. The data is saved to the database within the method of the Data Access Layer. Please help.

Here's my codebehind :

try
{
    OtherCompany om = new OtherCompany();
    NDAStaff ns = new NDAStaff();

    DateTime dt = Convert.ToDateTime(RadDatePicker1.SelectedDate);
    om.Date = dt.ToShortDateString();
    om.ComName = compName.Text;
    om.RegNumber = compReg.Text;
    om.Country = countryIncorp.Text;
    om.RegOfficeAddress = officeAddr.Text;
    om.ComRef = compRef.Text;
    om.CoreBuss = busiCore.Text;
    om.ComService = reqServ.Text;

    int index = servList.Items.Count;
    for (int i = 0; i < index; i++)
    {
        om.ReqServiceDetails[i] = servList.Items[i].Value;
    }

    om.ReprentName = fullName2.Text;
    om.ReprentDesig = desigOther.Text;
    om.Witness1Name = witFullName3.Text;
    om.Witness1Desig = witDesig1.Text;
    om.Witness1Address = witDept1.Text;
    om.Witness2Name = witFullName4.Text;
    om.Witness2Desig = witDesig4.Text;
    om.Witness2Adress = witAddr4.Text;

    ns.Staffname = fullName1.Text;
    ns.Designation = desigSriLan.Text;
    ns.Wit1Name = witFullName1.Text;
    ns.Wit1Designation = witDesig1.Text;
    ns.Wit1Department = witDept1.Text;
    ns.Wit2Name = witFullName2.Text;
    ns.Wit2Designation = witDesig2.Text;
    ns.Wit2Department = witDept2.Text;


    NDAGenProcessor ndap = new NDAGenProcessor();
    OtherCompanyProcessor ocp = new OtherCompanyProcessor(om);
    NDAstaffProcessor nsp = new NDAstaffProcessor();


    int NADid = ocp.createNDAID();
    //ndap.createPDF(om, ns, NADid);
    ocp.getCompanyDetails(NADid);
    nsp.addNDAstaffData(ns, NADid);
}

catch (Exception ex)
{
    throw ex;
}
leppie
  • 115,091
  • 17
  • 196
  • 297
ProblemChild
  • 556
  • 1
  • 8
  • 16

1 Answers1

0

If you want to know what line of code causes the exception, than go to Debug->Exceptions and check the box Thrown Common Language Runtime Exceptions.

You will get so called First Chance Exception. Then debug your code and the debugger will stop in that very line which causes the exception.

EngineerSpock
  • 2,575
  • 4
  • 35
  • 57
  • The exception throws from the "for" loop. The "for" loop is required as I have to load all the items from a listbox to an object and save the items as a string in the database. – ProblemChild Feb 26 '15 at 08:07