input string not in correct format

A

amitbadgi

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

%>
 
N

Nick Malik [Microsoft]

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

%>
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top