Need help on correct input string format  
Author Message
traderhen





PostPosted: Visual C# General, Need help on correct input string format Top

I'm getting the following run time exception below.


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:

Line 355:				if ((TheDataRow["type"].ToString() == "Outage" ) || (TheDataRow["type"].ToString() == "TR Outage")) 
Line 356: {
Line 357: if ( (Convert.ToInt32( TheDataRow["outCurrentCustomersEffected"].ToString() )) > 1 )
Line 358: {
Line 359: return false;



Visual C#3  
 
 
ahmedilyas





PostPosted: Visual C# General, Need help on correct input string format Top

  • does TheDataRow
  • ["outCurrentCustomersEffected"] contain a value

  • is that value a numeric value

    if you are using .NET 2.0, try the int.TryParse and see what happens also....example

    int result = -1;

    if (int.TryParse(TheDataRow

  • ["outCurrentCustomersEffected"].ToString(), out result))

    {

       //converted result to integer, result stored in the variable "result"

    }

    else

    {

       //value was not a numeric/int value

    }



     
     
    traderhen





    PostPosted: Visual C# General, Need help on correct input string format Top

    The problem was the 1st point you mentioned - outCurrentCustomersEffected did not contain a value.

    Thanks.