input string not in correct format

Discussion in 'ASP .Net' started by amitbadgi@gmail.com, Aug 12, 2005.

  1. Guest

    I am gettign this error, while migration an app to asp.net

    Exception Details: System.FormatException: Input string was not in a
    correct format.

    Source Error:

    Line 19: Dim enddate = request.QueryString("enddate")
    Line 20:
    Line 21: if cint(eventid) = "0" then
    Line 22: searchtype = 0
    Line 23: else


    Source File: C:\Documents and
    Settings\amit\WebSite1\reports\loc_summary_calc.aspx Line: 21

    Stack Trace:

    [FormatException: Input string was not in a correct format.]
    Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String
    Value, NumberFormatInfo NumberFormat) +216
    Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String
    Value) +91[InvalidCastException: Conversion from string "ns" to type
    'Integer' is not valid.]
    Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String
    Value) +247
    Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(Object
    Value) +988
    ASP.loc_summary_calc_aspx.__Render__control1(HtmlTextWriter __w,
    Control parameterContainer) in C:\Documents and
    Settings\amit\WebSite1\reports\loc_summary_calc.aspx:21
    System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
    ICollection children) +98
    System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
    System.Web.UI.Page.Render(HtmlTextWriter writer) +27
    System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,
    ControlAdapter adapter) +53
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
    ControlAdapter adapter) +278
    System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +24The code
    isdim eventid, subeventid, cyear, searchalleventeventid =
    request.QueryString("VIOSel1")subeventid =
    request.QueryString("subvioSel1")cyear =
    request.QueryString("cyear")searchallevent =
    request.QueryString("searchall")Dim startdate =
    request.QueryString("startdate")Dim enddate =
    request.QueryString("enddate")
    System.Web.UI.Page.ProcessRequestMain(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    +8937

    The code is as follows,
    <%
    dim searchtype
    '0 - search all zone
    '1 - search by zone
    '2 - search by location



    dim eventid, subeventid, cyear, searchallevent

    eventid = request.QueryString("VIOSel1")
    subeventid = request.QueryString("subvioSel1")
    cyear = request.QueryString("cyear")
    searchallevent = request.QueryString("searchall")
    Dim startdate = request.QueryString("startdate")
    Dim enddate = request.QueryString("enddate")

    if cint(eventid).ToString() = 0 then
    searchtype = 0
    else
    if cint(subeventid) = 0 then
    searchtype = 1
    else
    searchtype = 2
    end if
    end if


    Dim Command1__startdate
    Command1__startdate = startdate

    Dim Command1__enddate
    Command1__enddate = enddate

    %>
     
    , Aug 12, 2005
    #1
    1. Advertising

  2. your conversion is strange. Your source line says >if cint(eventid) = 0
    then
    while your destination line says >if cint(eventid) = "0" then

    In the source line, you are taking a string (eventid) and converting to an
    integer, and comparing against zero (note that cint will return a zero for
    any non-numeric value, including a null string). In the new line, you are
    taking a string, converting to an integer, and then comparing against the
    string "0" which is not valid. In addition, the cint() function may not be
    as forgiving in vb.net as it was in vb.

    Why not check to make sure that the value isn't null or non-numeric, instead
    of attempting to convert it and looking for a failure?

    --
    --- Nick Malik [Microsoft]
    MCSD, CFPS, Certified Scrummaster
    http://blogs.msdn.com/nickmalik

    Disclaimer: Opinions expressed in this forum are my own, and not
    representative of my employer.
    I do not answer questions on behalf of my employer. I'm just a
    programmer helping programmers.
    --
    <> wrote in message
    news:...
    >I am gettign this error, while migration an app to asp.net
    >
    > Exception Details: System.FormatException: Input string was not in a
    > correct format.
    >
    > Source Error:
    >
    > Line 19: Dim enddate = request.QueryString("enddate")
    > Line 20:
    > Line 21: if cint(eventid) = "0" then
    > Line 22: searchtype = 0
    > Line 23: else
    >
    >
    > Source File: C:\Documents and
    > Settings\amit\WebSite1\reports\loc_summary_calc.aspx Line: 21
    >
    > Stack Trace:
    >
    > [FormatException: Input string was not in a correct format.]
    > Microsoft.VisualBasic.CompilerServices.Conversions.ParseDouble(String
    > Value, NumberFormatInfo NumberFormat) +216
    > Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String
    > Value) +91[InvalidCastException: Conversion from string "ns" to type
    > 'Integer' is not valid.]
    > Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(String
    > Value) +247
    > Microsoft.VisualBasic.CompilerServices.Conversions.ToInteger(Object
    > Value) +988
    > ASP.loc_summary_calc_aspx.__Render__control1(HtmlTextWriter __w,
    > Control parameterContainer) in C:\Documents and
    > Settings\amit\WebSite1\reports\loc_summary_calc.aspx:21
    > System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
    > ICollection children) +98
    > System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +20
    > System.Web.UI.Page.Render(HtmlTextWriter writer) +27
    > System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer,
    > ControlAdapter adapter) +53
    > System.Web.UI.Control.RenderControl(HtmlTextWriter writer,
    > ControlAdapter adapter) +278
    > System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +24The code
    > isdim eventid, subeventid, cyear, searchalleventeventid =
    > request.QueryString("VIOSel1")subeventid =
    > request.QueryString("subvioSel1")cyear =
    > request.QueryString("cyear")searchallevent =
    > request.QueryString("searchall")Dim startdate =
    > request.QueryString("startdate")Dim enddate =
    > request.QueryString("enddate")
    > System.Web.UI.Page.ProcessRequestMain(Boolean
    > includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    > +8937
    >
    > The code is as follows,
    > <%
    > dim searchtype
    > '0 - search all zone
    > '1 - search by zone
    > '2 - search by location
    >
    >
    >
    > dim eventid, subeventid, cyear, searchallevent
    >
    > eventid = request.QueryString("VIOSel1")
    > subeventid = request.QueryString("subvioSel1")
    > cyear = request.QueryString("cyear")
    > searchallevent = request.QueryString("searchall")
    > Dim startdate = request.QueryString("startdate")
    > Dim enddate = request.QueryString("enddate")
    >
    > if cint(eventid).ToString() = 0 then
    > searchtype = 0
    > else
    > if cint(subeventid) = 0 then
    > searchtype = 1
    > else
    > searchtype = 2
    > end if
    > end if
    >
    >
    > Dim Command1__startdate
    > Command1__startdate = startdate
    >
    > Dim Command1__enddate
    > Command1__enddate = enddate
    >
    > %>
    >
     
    Nick Malik [Microsoft], Aug 12, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. phmyhn
    Replies:
    0
    Views:
    11,440
    phmyhn
    Jun 24, 2003
  2. TJS
    Replies:
    0
    Views:
    1,361
  3. sbox
    Replies:
    2
    Views:
    15,367
    Ben Miller [MSFT]
    Feb 15, 2004
  4. Replies:
    0
    Views:
    628
  5. chongo
    Replies:
    2
    Views:
    8,185
    Edward
    Jul 8, 2004
Loading...

Share This Page