Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / August 2005

Tip: Looking for answers? Try searching our database.

input string not in correct format

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
amitbadgi@gmail.com - 12 Aug 2005 06:59 GMT
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] - 12 Aug 2005 07:32 GMT
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?

Signature

--- 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.
--

>I am gettign this error, while migration an app to asp.net
>
[quoted text clipped - 80 lines]
>
> %>

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.