Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Try Catch Not working porperly...

Try Catch Not working porperly...

Scheduled Pinned Locked Moved ASP.NET
help
14 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dev S
    wrote on last edited by
    #1

    Hi, In my website i have a report where i have implemented try-catch try { ... ... } catch(Exception) { return; } but even on appling try-catch on every event my report sometimes gives error like "INPUT STRING IS NOT IN CORRECT FORMAT". I have tried my best so that data type mismatch should not occur. This problem is significant with this report only. Help me.

    S A Y 3 Replies Last reply
    0
    • D Dev S

      Hi, In my website i have a report where i have implemented try-catch try { ... ... } catch(Exception) { return; } but even on appling try-catch on every event my report sometimes gives error like "INPUT STRING IS NOT IN CORRECT FORMAT". I have tried my best so that data type mismatch should not occur. This problem is significant with this report only. Help me.

      S Offline
      S Offline
      SeMartens
      wrote on last edited by
      #2

      I guess the exception is catched within the report, so that your try-catch-statement will not be executed.

      It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

      D 1 Reply Last reply
      0
      • S SeMartens

        I guess the exception is catched within the report, so that your try-catch-statement will not be executed.

        It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

        D Offline
        D Offline
        Dev S
        wrote on last edited by
        #3

        I cant understand what you mean by this. If i am handling the exception before any function or data conversion executes then how this error can come.

        S C 2 Replies Last reply
        0
        • D Dev S

          I cant understand what you mean by this. If i am handling the exception before any function or data conversion executes then how this error can come.

          S Offline
          S Offline
          SeMartens
          wrote on last edited by
          #4

          Is an exception thrown? If not, how is the error displayed, within the report?

          It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

          D 1 Reply Last reply
          0
          • S SeMartens

            Is an exception thrown? If not, how is the error displayed, within the report?

            It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.

            D Offline
            D Offline
            Dev S
            wrote on last edited by
            #5

            The error appears like this --> Server Error in '/' Application. -------------------------------------------------------------------------------- Input string was not in a correct format. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.FormatException: Input string was not in a correct format. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [FormatException: Input string was not in a correct format.] System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +7469351 System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119 System.Web.UI.WebControls.ImageButton.LoadPostData(String postDataKey, NameValueCollection postCollection) +163 System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +14 System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +693 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1743 -------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082

            A 1 Reply Last reply
            0
            • D Dev S

              The error appears like this --> Server Error in '/' Application. -------------------------------------------------------------------------------- Input string was not in a correct format. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.FormatException: Input string was not in a correct format. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [FormatException: Input string was not in a correct format.] System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +7469351 System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +119 System.Web.UI.WebControls.ImageButton.LoadPostData(String postDataKey, NameValueCollection postCollection) +163 System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection) +14 System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +693 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1743 -------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082

              A Offline
              A Offline
              Abhijit Jana
              wrote on last edited by
              #6

              What was the input string? Is there any special character on that string ?

              cheers, Abhijit CodeProject MVP

              D 1 Reply Last reply
              0
              • A Abhijit Jana

                What was the input string? Is there any special character on that string ?

                cheers, Abhijit CodeProject MVP

                D Offline
                D Offline
                Dev S
                wrote on last edited by
                #7

                Hi Abhijit, Even on entering special charatcers , report is working fine. I cant fnd this error on local and only once on server but my clients have reported it many times. I am not undertaking any data conversions. I have text boxes for dates and i have tested it several times they are working fine. Even I cant understand why this error is coming as on local and even on server i cant find this error except only 1 time with all types of input.

                A 1 Reply Last reply
                0
                • D Dev S

                  Hi Abhijit, Even on entering special charatcers , report is working fine. I cant fnd this error on local and only once on server but my clients have reported it many times. I am not undertaking any data conversions. I have text boxes for dates and i have tested it several times they are working fine. Even I cant understand why this error is coming as on local and even on server i cant find this error except only 1 time with all types of input.

                  A Offline
                  A Offline
                  Abhijit Jana
                  wrote on last edited by
                  #8

                  devesh sinha wrote:

                  I cant fnd this error on local and only once on server but my clients have reported it many times.

                  Then why you are not asking client for data and tested with those data. I think there may be some script problem.

                  cheers, Abhijit CodeProject MVP

                  D 1 Reply Last reply
                  0
                  • A Abhijit Jana

                    devesh sinha wrote:

                    I cant fnd this error on local and only once on server but my clients have reported it many times.

                    Then why you are not asking client for data and tested with those data. I think there may be some script problem.

                    cheers, Abhijit CodeProject MVP

                    D Offline
                    D Offline
                    Dev S
                    wrote on last edited by
                    #9

                    On this page i have only two textboxes for input that are used for entering dates. And i have tested it with every type of incorrect input. It is not giving any error.

                    A 1 Reply Last reply
                    0
                    • D Dev S

                      On this page i have only two textboxes for input that are used for entering dates. And i have tested it with every type of incorrect input. It is not giving any error.

                      A Offline
                      A Offline
                      Abhijit Jana
                      wrote on last edited by
                      #10

                      Did you tried with this < > cheers, Abhijit CodeProject MVP

                      1 Reply Last reply
                      0
                      • D Dev S

                        Hi, In my website i have a report where i have implemented try-catch try { ... ... } catch(Exception) { return; } but even on appling try-catch on every event my report sometimes gives error like "INPUT STRING IS NOT IN CORRECT FORMAT". I have tried my best so that data type mismatch should not occur. This problem is significant with this report only. Help me.

                        A Offline
                        A Offline
                        Arindam Tewary
                        wrote on last edited by
                        #11

                        What is the retuen type of your function ?? and if exception occurs then what are you returning ?? If you dont know the meaning of what I am asking you please post your function here and the line from where you have called the function !! :)

                        Thanks, Arindam D Tewary

                        D 1 Reply Last reply
                        0
                        • A Arindam Tewary

                          What is the retuen type of your function ?? and if exception occurs then what are you returning ?? If you dont know the meaning of what I am asking you please post your function here and the line from where you have called the function !! :)

                          Thanks, Arindam D Tewary

                          D Offline
                          D Offline
                          Dev S
                          wrote on last edited by
                          #12

                          Hi, Here is my code. <code> public partial class SCSFMS_Pages_VisitLog : System.Web.UI.Page { Common cmn = new Common(); protected void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { SessionExpiresCheckOnButton(); try { hiUid.Text = Session["Usr_Id"].ToString(); hidUtype.Text = Session["UserType"].ToString(); string curdt = System.DateTime.Now.AddHours(13).ToString("dd/MM/yyyy"); string entrydt = cmn.DDMMYYtoMMDDYY(curdt); txtDate.Text = curdt; txtVisitDtto.Text = curdt; if (hidUtype.Text == "A") { cmn.fillDDL(ddlUser, "select u.Usr_Id,u.UName from users u, userdetail ud where u.status ='Active' and ud.designationid in (2,4,12) and ud.id=u.usr_id order by UName", "Usr_Id", "UName"); } string desigid = cmn.nDesgID(hiUid.Text).ToString(); if (hidUtype.Text == "U") { if (desigid == "6") { cmn.fillDDL(ddlUser, "select u.Usr_Id,u.UName from users u, userdetail ud where u.status ='Active' and ud.id=u.usr_id and (ud.id ="+hiUid.Text+" or ud.admintoreport="+hiUid.Text+") order by UName", "Usr_Id", "UName"); } else { cmn.fillDDL(ddlUser, "select u.Usr_Id,u.UName from users u, userdetail ud where u.status ='Active' and ud.id=u.usr_id and (ud.id =" + hiUid.Text + ") order by UName", "Usr_Id", "UName"); ddlUser.SelectedIndex= 1; ddlUser.UpdateAfterCallBack = true; } } } catch (Exception ex) { return; } } } protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { try { fillgrid(); } catch (Exception ex) { return; } } public void fillgrid() { try { string usrsearch = ""; string sqlprt = ""; string desigid = cmn.nDesgID(hiUid.Text).ToString(); if (ddlUser.SelectedValue != "0") { usrsearch

                          1 Reply Last reply
                          0
                          • D Dev S

                            Hi, In my website i have a report where i have implemented try-catch try { ... ... } catch(Exception) { return; } but even on appling try-catch on every event my report sometimes gives error like "INPUT STRING IS NOT IN CORRECT FORMAT". I have tried my best so that data type mismatch should not occur. This problem is significant with this report only. Help me.

                            Y Offline
                            Y Offline
                            Yusuf
                            wrote on last edited by
                            #13

                            try to catch me if you can :jig: some one is eating the exception. If the exception is not re-thrown then there is nothing you can do.

                            Yusuf Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]

                            1 Reply Last reply
                            0
                            • D Dev S

                              I cant understand what you mean by this. If i am handling the exception before any function or data conversion executes then how this error can come.

                              C Offline
                              C Offline
                              Christian Graus
                              wrote on last edited by
                              #14

                              Have you tried steppg through the code ?

                              Christian Graus Driven to the arms of OSX by Vista. "I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups