• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 525
  • Last Modified:

How do I investiage / debug what is wrong with my ExecuteNonQuery command?

For the life of me, I can't figure out what is wrong with my ExecuteNonQuery command, but it stops the web application and shuts down the browser window (in Chrome), when I'm in the debugger. I've got it in a try...catch block but as soon as it hits the command it shuts everything down. How can I debug this or figure out what is going on with this command?

        public static void saveNewInspection(ref Inspection theInspection)
        {
            //we only populate the first page of the Inspection data - after this we call UPDATE for subsequent pages

            StringBuilder sbSQL = new StringBuilder();

            //int InspNum = (ArrowGlobalFunc.getMaxInspectionSeqNo()) + 1;
            //theInspection.InspectionID = InspNum;

            using (iDB2Connection conn = new iDB2Connection(ArrowStrings.strConnIseries))
            {
                bool bIsNew = false;
                conn.Open();

                if (theInspection.InspectionID == 0 || HttpContext.Current.Session["ISPNUM"].ToString() == "0" || HttpContext.Current.Session["ISPNUM"].ToString() == "")
                {
                    bIsNew = true;

                    int InspNum = (ArrowGlobalFunc.getMaxInspectionSeqNo()) + 1;
                    theInspection.InspectionID = InspNum;

                    HttpContext.Current.Session["ISPNUM"] = InspNum.ToString();

                    sbSQL.Append("INSERT INTO " + HttpContext.Current.Session["Library"].ToString() + ".INSPECTION (ISPNUM, ");
                    // Spec 1
                    sbSQL.Append("ISPVIN, ISPVIN6, ISPFLEET, ISPUNIT, ISPPHONE, ISPEXT, ISPLOC, ISPCONTACT, ISPADDR, ISPCITY, ISPSTATE, ");
                    sbSQL.Append("ISPZIP, ISPUNITYY, ISPMAKE, ISPMODEL, ISPEMAKE, ISPSRC, ISPDPF, ISPEMODL, ISPENGSERL, ISPENGCPL, ISPHPRATE, ISPBUMPER, ");
                    sbSQL.Append("ISPDUALBDS, ISPBLDMM, ISPBLDYY, ISPSLEEPER, ISPSLEEPSZ, ISPWHEELBS, ISPENGBRK, ISPPOWERST, ISPAIR, ISPINTTYPE, ");
                    sbSQL.Append("ISPINTLEVL, ISPINTUPH, ISPSEATSUS, ISPINTCOLR, ISPPAINT, ISPMIRRORS, ISPMIRRPWR, ISPRADIO6, ISPRADIO2, ");
                    sbSQL.Append("ISPRADIO3, ISPRADIO1, ISPRADIO5, ISPRADIO4, ISPENGFAMC, ISPENGHOUR, ISPHPECU, ICARFAX, ISPTRECDT, ISPODOM, ISPECU, ISPNEWSYS, ");
                    sbSQL.Append("ISPUSERNUM, REQID1, ISPREQDT1) ");

                    sbSQL.Append("VALUES(" + InspNum.ToString() + ", ");
                    // Spec 1
                    sbSQL.Append("@ISPVIN, @ISPVIN6, @ISPFLEET, @ISPUNIT, @ISPPHONE, @ISPEXT, @ISPLOC, @ISPCONTACT, @ISPADDR, @ISPCITY, @ISPSTATE, ");
                    sbSQL.Append("@ISPZIP, @ISPUNITYY, @ISPMAKE, @ISPMODEL, @ISPEMAKE, @ISPSRC, @ISPDPF, @ISPEMODL, @ISPENGSERL, @ISPENGCPL, @ISPHPRATE, @ISPBUMPER, ");
                    sbSQL.Append("@ISPDUALBDS, @ISPBLDMM, @ISPBLDYY, @ISPSLEEPER, @ISPSLEEPSZ, @ISPWHEELBS, @ISPENGBRK, @ISPPOWERST, @ISPAIR, @ISPINTTYPE, ");
                    sbSQL.Append("@ISPINTLEVL, @ISPINTUPH, @ISPSEATSUS, @ISPINTCOLR, @ISPPAINT, @ISPMIRRORS, @ISPMIRRPWR, @ISPRADIO6, @ISPRADIO2, ");
                    sbSQL.Append("@ISPRADIO3, @ISPRADIO1, @ISPRADIO5, @ISPRADIO4, @ISPENGFAMC, @ISPENGHOUR, @ISPHPECU, @ICARFAX, @ISPTRECDT, @ISPODOM, @ISPECU, 1, ");
                    sbSQL.Append("@ISPUSERNUM, @REQID1, @ISPREQDT1)");
                }
                else
                {
                    sbSQL.Append("UPDATE " + HttpContext.Current.Session["Library"].ToString() + ".INSPECTION SET ");
                    sbSQL.Append("ISPVIN = @ISPVIN, ");
                    sbSQL.Append("ISPVIN6 = @ISPVIN6, ");
                    sbSQL.Append("ISPFLEET = @ISPFLEET, ");
                    sbSQL.Append("ISPUNIT = @ISPUNIT, ");
                    sbSQL.Append("ISPPHONE = @ISPPHONE, ");
                    sbSQL.Append("ISPEXT = @ISPEXT, ");
                    sbSQL.Append("ISPLOC = @ISPLOC, ");
                    sbSQL.Append("ISPCONTACT = @ISPCONTACT, ");
                    sbSQL.Append("ISPADDR = @ISPADDR, ");
                    sbSQL.Append("ISPCITY = @ISPCITY, ");
                    sbSQL.Append("ISPSTATE = @ISPSTATE, ");
                    sbSQL.Append("ISPZIP = @ISPZIP, ");
                    sbSQL.Append("ISPUNITYY = @ISPUNITYY, ");
                    sbSQL.Append("ISPMAKE = @ISPMAKE, ");
                    sbSQL.Append("ISPMODEL = @ISPMODEL, ");
                    sbSQL.Append("ISPEMAKE = @ISPEMAKE, ");
                    sbSQL.Append("ISPSRC = @ISPSRC, ");
                    sbSQL.Append("ISPDPF = @ISPDPF, ");
                    sbSQL.Append("ISPEMODL = @ISPEMODL, ");
                    sbSQL.Append("ISPENGSERL = @ISPENGSERL, ");
                    sbSQL.Append("ISPENGCPL = @ISPENGCPL, ");
                    sbSQL.Append("ISPHPRATE = @ISPHPRATE, ");
                    sbSQL.Append("ISPBUMPER = @ISPBUMPER, ");
                    sbSQL.Append("ISPDUALBDS = @ISPDUALBDS, ");
                    sbSQL.Append("ISPBLDMM = @ISPBLDMM, ");
                    sbSQL.Append("ISPBLDYY = @ISPBLDYY, ");
                    sbSQL.Append("ISPSLEEPER = @ISPSLEEPER, ");
                    sbSQL.Append("ISPSLEEPSZ = @ISPSLEEPSZ, ");
                    sbSQL.Append("ISPWHEELBS = @ISPWHEELBS, ");
                    sbSQL.Append("ISPENGBRK = @ISPENGBRK, ");
                    sbSQL.Append("ISPPOWERST = @ISPPOWERST, ");
                    sbSQL.Append("ISPAIR = @ISPAIR, ");
                    sbSQL.Append("ISPINTTYPE = @ISPINTTYPE, ");
                    sbSQL.Append("ISPINTLEVL = @ISPINTLEVL, ");
                    sbSQL.Append("ISPINTUPH = @ISPINTUPH, ");
                    sbSQL.Append("ISPSEATSUS = @ISPSEATSUS, ");
                    sbSQL.Append("ISPINTCOLR = @ISPINTCOLR, ");
                    sbSQL.Append("ISPPAINT = @ISPPAINT, ");
                    //sbSQL.Append("ISPNEWPNT = @ISPNEWPNT, ");
                    sbSQL.Append("ISPMIRRORS = @ISPMIRRORS, ");
                    sbSQL.Append("ISPMIRRPWR = @ISPMIRRPWR, ");
                    sbSQL.Append("ISPRADIO6 = @ISPRADIO6, ");
                    sbSQL.Append("ISPRADIO2 = @ISPRADIO2, ");
                    sbSQL.Append("ISPRADIO3 = @ISPRADIO3, ");
                    sbSQL.Append("ISPRADIO1 = @ISPRADIO1, ");
                    sbSQL.Append("ISPRADIO5 = @ISPRADIO5, ");
                    sbSQL.Append("ISPRADIO4 = @ISPRADIO4, ");
                    sbSQL.Append("ISPENGFAMC = @ISPENGFAMC, ");
                    sbSQL.Append("ISPENGHOUR = @ISPENGHOUR, ");
                    sbSQL.Append("ISPHPECU = @ISPHPECU, ");
                    sbSQL.Append("ICARFAX = @ICARFAX, ");
                    //sbSQL.Append("ICLEANDEC = @ICLEANDEC, ");
                    sbSQL.Append("ISPTRECDT = @ISPTRECDT, ");
                    sbSQL.Append("ISPODOM = @ISPODOM, ");
                    sbSQL.Append("ISPECU = @ISPECU ");
                    sbSQL.Append("WHERE ISPNUM = " + HttpContext.Current.Session["ISPNUM"].ToString());
                }

                using (iDB2Command cmd = new iDB2Command(sbSQL.ToString(), conn))
                {

                    // Spec 1
                    cmd.Parameters.Add(new iDB2Parameter("ISPVIN", theInspection.FullVin));
                    cmd.Parameters.Add(new iDB2Parameter("ISPVIN6", theInspection.VinNo)); // Only Admins can change this
                    cmd.Parameters.Add(new iDB2Parameter("ISPFLEET", theInspection.Fleet));
                    cmd.Parameters.Add(new iDB2Parameter("ISPUNIT", theInspection.Units));
                    cmd.Parameters.Add(new iDB2Parameter("ISPPHONE", theInspection.Phone));
                    cmd.Parameters.Add(new iDB2Parameter("ISPEXT", theInspection.Ext));
                    cmd.Parameters.Add(new iDB2Parameter("ISPLOC", theInspection.Location));
                    cmd.Parameters.Add(new iDB2Parameter("ISPCONTACT", theInspection.Contact));
                    cmd.Parameters.Add(new iDB2Parameter("ISPADDR", theInspection.Addr));
                    cmd.Parameters.Add(new iDB2Parameter("ISPCITY", theInspection.City));
                    cmd.Parameters.Add(new iDB2Parameter("ISPSTATE", theInspection.State));
                    cmd.Parameters.Add(new iDB2Parameter("ISPZIP", theInspection.Zip));
                    cmd.Parameters.Add(new iDB2Parameter("ISPUNITYY", theInspection.mYear));
                    cmd.Parameters.Add(new iDB2Parameter("ISPMAKE", theInspection.Make));
                    cmd.Parameters.Add(new iDB2Parameter("ISPMODEL", theInspection.Model));
                    cmd.Parameters.Add(new iDB2Parameter("ISPEMAKE", theInspection.EngMake));
                    cmd.Parameters.Add(new iDB2Parameter("ISPSRC", theInspection.SRC));
                    cmd.Parameters.Add(new iDB2Parameter("ISPDPF", theInspection.DPF));
                    cmd.Parameters.Add(new iDB2Parameter("ISPEMODL", theInspection.EngModel));
                    cmd.Parameters.Add(new iDB2Parameter("ISPENGSERL", theInspection.EngSerial));
                    cmd.Parameters.Add(new iDB2Parameter("ISPENGCPL", theInspection.EngCpl));
                    cmd.Parameters.Add(new iDB2Parameter("ISPHPRATE", theInspection.HPrated));
                    cmd.Parameters.Add(new iDB2Parameter("ISPBUMPER", theInspection.Bumper));
                    cmd.Parameters.Add(new iDB2Parameter("ISPDUALBDS", theInspection.DualBed));
                    cmd.Parameters.Add(new iDB2Parameter("ISPBLDMM", theInspection.BuildMM));
                    cmd.Parameters.Add(new iDB2Parameter("ISPBLDYY", theInspection.BuildYY));
                    cmd.Parameters.Add(new iDB2Parameter("ISPSLEEPER", theInspection.Sleeper));
                    cmd.Parameters.Add(new iDB2Parameter("ISPSLEEPSZ", theInspection.SlpSize));
                    cmd.Parameters.Add(new iDB2Parameter("ISPWHEELBS", theInspection.Wheelbase));
                    cmd.Parameters.Add(new iDB2Parameter("ISPENGBRK", theInspection.EngBrake));
                    cmd.Parameters.Add(new iDB2Parameter("ISPPOWERST", theInspection.PwrSteer));
                    cmd.Parameters.Add(new iDB2Parameter("ISPAIR", theInspection.Aircon));
                    cmd.Parameters.Add(new iDB2Parameter("ISPINTTYPE", theInspection.IntType));
                    cmd.Parameters.Add(new iDB2Parameter("ISPINTLEVL", theInspection.IntLevel));
                    cmd.Parameters.Add(new iDB2Parameter("ISPINTUPH", theInspection.IntUphol));
                    cmd.Parameters.Add(new iDB2Parameter("ISPSEATSUS", theInspection.SeatSus));
                    cmd.Parameters.Add(new iDB2Parameter("ISPINTCOLR", theInspection.IntColor));
                    cmd.Parameters.Add(new iDB2Parameter("ISPPAINT", theInspection.Color));
                    //cmd.Parameters.Add(new iDB2Parameter("ISPNEWPNT", theInspection.Nupaint));
                    cmd.Parameters.Add(new iDB2Parameter("ISPMIRRORS", theInspection.MirrorsHt));
                    cmd.Parameters.Add(new iDB2Parameter("ISPMIRRPWR", theInspection.MirrorsPwr));
                    cmd.Parameters.Add(new iDB2Parameter("ISPRADIO6", theInspection.RadNone));
                    cmd.Parameters.Add(new iDB2Parameter("ISPRADIO2", theInspection.RadCass));
                    cmd.Parameters.Add(new iDB2Parameter("ISPRADIO3", theInspection.RadCD));
                    cmd.Parameters.Add(new iDB2Parameter("ISPRADIO1", theInspection.RadFM));
                    cmd.Parameters.Add(new iDB2Parameter("ISPRADIO5", theInspection.RadSatelite));
                    cmd.Parameters.Add(new iDB2Parameter("ISPRADIO4", theInspection.RadWB));
                    cmd.Parameters.Add(new iDB2Parameter("ISPENGFAMC", theInspection.EngFamilyCodes));
                    cmd.Parameters.Add(new iDB2Parameter("ISPENGHOUR", theInspection.EngHrs));
                    cmd.Parameters.Add(new iDB2Parameter("ISPHPECU", theInspection.HPecu));
                    cmd.Parameters.Add(new iDB2Parameter("ICARFAX", theInspection.HistRptReviewed));
                    //cmd.Parameters.Add(new iDB2Parameter("ICLEANDEC", theInspection.CleanIdleDecal));
                    cmd.Parameters.Add(new iDB2Parameter("ISPTRECDT", theInspection.TitleReceivedDate));
                    cmd.Parameters.Add(new iDB2Parameter("ISPODOM", theInspection.Odometer));
                    cmd.Parameters.Add(new iDB2Parameter("ISPECU", theInspection.ECUint));

                    if (bIsNew)
                    {
                        cmd.Parameters.Add(new iDB2Parameter("ISPUSERNUM", HttpContext.Current.Session["uID"].ToString()));
                        cmd.Parameters.Add(new iDB2Parameter("REQID1", HttpContext.Current.Session["uID"].ToString()));
                        cmd.Parameters.Add(new iDB2Parameter("ISPREQDT1", ArrowGlobalFunc.convertDateToInt(DateTime.Now.ToShortDateString())));
                    }

                    try
                    {
                        cmd.ExecuteNonQuery();  <---HERE: BOOM! and then nada/nunca/zip/zero
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }
        }

Open in new window

0
Michael Sterling
Asked:
Michael Sterling
  • 2
1 Solution
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
I was able to get this far, but not sure what this means or how to proceed with resolving this. Help please?
javaScriptError.PNG
0
 
balderCommented:
I guess you are developing this in visual studio, if so then:
* put a breakpoint on the cmd.ExecuteNonQuery() line
* run the app til it hit the breakpoint
* in visual studio Debug->Exceptions : Break when an exception is thrown, enable C++ Exceptions, Common Language Exceptions, Win32 Exceptions
* confirm that Tools->Options : Debugging General, Enable Just My Code is unchecked
* confirm that your projects properties for Web app has enabled ASP.NET og Native Code debuggers
* continue running your app

The app should now automatically break where the error is.
0
 
käµfm³d 👽Commented:
You're swallowing the exception in lines 174 - 176, so how would you possibly know what's wrong? Have you inspected "ex" when the exception is raised?
0
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now