Try Catch Not working porperly...
-
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.
-
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.
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.
-
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.
-
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.
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.
-
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.
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
-
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
What was the input string? Is there any special character on that string ?
cheers, Abhijit CodeProject MVP
-
What was the input string? Is there any special character on that string ?
cheers, Abhijit CodeProject MVP
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.
-
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.
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
-
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
-
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.
Did you tried with this < > cheers, Abhijit CodeProject MVP
-
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.
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
-
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
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
-
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.
try
tocatch
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[^]
-
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.
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 )