469,927 Members | 1,784 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,927 developers. It's quick & easy.

trying to find source of error

I'm new to .NET and I have a error that is coming up but it's not telling me
where the error is coming from (no file). Is that because I'm doing
something wrong...or is it a type of error that has nothing to do with my
code? P.S. I'm debugging someone else's code. Here's what the screen looks
like when I load the page:

************************************************** *
Input String was not in a correct format

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.ParseInt32(String s, NumberStyles style, NumberFormatInfo
info) +0
System.Int32.Parse(String s) +38
customer.OrderDetail.loadDetail()
customer.OrderDetail.Page_Load(Object sender, EventArgs e)
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
************************************************** *

Any help is greatly appreciated.

-bruce duncan

Nov 18 '05 #1
3 1182
Bruce -
You probably have a page called OrderDetail.aspx. There's a matching
file, either OrderDetail.aspx.vb or OrderDetail.aspx.cs. That page has
a function called loadDetail that is reading an OrderDetail ID number
from something, possibly the Query String. It's expecting the value to
be an integer, but it's getting something it can't convert to an
integer.

I'd set a breakpoint on the loadDetail function and run the application
in Debug mode, then step through the loadDetail function when the
breakpoint hits and see where it blows up.
- Jon
http://weblogs.asp.net/jgalloway

Nov 18 '05 #2
>
I'd set a breakpoint on the loadDetail function and run the application
in Debug mode, then step through the loadDetail function when the
breakpoint hits and see where it blows up.
- Jon
http://weblogs.asp.net/jgalloway


Jon,
Thanks for the advice. Since I'm developing this project on a PC other than
the web server, I can't run it in debug mode (or at least I can't get it to
work). So, I've been trying to narrow down the possible bugs...here's my
function...any thoughts?

private void loadDetail()
{
string orderdtlSQL = "select orderqty, ium, partnum, linedesc, unitprice
from pub.orderdtl where company='OGI' and ordernum = '" + ordernum + "' and
custnum = " + custnum;
DataTable table = d.getDataTable("vntg",orderdtlSQL);
table.Columns.Add("extprice");
int ShipQty = 0;
foreach(DataRow row in table.Rows)
{
// extprice = qty * unitprice
row["extprice"] = Single.Parse(row["orderqty"].ToString()) *
Single.Parse(row["unitprice"].ToString());
// accumulate qty
ShipQty += Int32.Parse(row["orderqty"].ToString());
}
this.lblQtyTotal.Text = ShipQty.ToString();
this.rptOrderDetail.DataSource = table;
this.rptOrderDetail.DataBind();

}

Thanks,
bruce

Nov 18 '05 #3
Bruce -
It looks from the stack trace that the error is on this line:
ShipQty += Int32.Parse(row["orderqty"].ToString());

You should check your data to see if you have non-numeric data in your
orderqty field. From your code, this SQL statement would probably find
it:
select * from pub.orderdtl where company='OGI' and isnumeric(orderqty)
= 0;

Additionally, you could wrap the line that's throwing the exception
with a try / catch:

try
{
ShipQty += Int32.Parse(row["orderqty"].ToString());
}
catch (Exception e)
{
Context.Trace.Warn("Exception", "Non-numeric ORDERQTY", e);
}

The Context.Trace.Warn statement writes the error info out to the
ASP.NET trace. If you're not familiar with that, this article is a good
place to start:
http://msdn.microsoft.com/library/de...sp01252001.asp
- Jon
http://weblogs.asp.net/jgalloway

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by David Shorthouse | last post: by
6 posts views Thread by Frank Wilson | last post: by
12 posts views Thread by Phil Certain | last post: by
2 posts views Thread by msnews.microsoft.com | last post: by
reply views Thread by Henrik Stidsen | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.