Computed field in temp table causes error in .NET

J

John Dalberg

I am getting "Input string was not in a correct format" error in a line
like this:
Int32.Parse(((DataRowView)e.Item.DataItem).Row.ItemArray[8].ToString())

Field #8 comes from a SQL Server stored proc. The stored proc returns a
select statement from a temp table. The temp table was created by a select
into statement like this select .........., 0.5 * another column into #temp

What data type does #8 have in the framework when it's returned by ado.net?
Because when I use the debugger and have a watch on the object returned,
the object is a number however inside the watch window, it doesn't have a
curly braces nor double quotes around it so I am guessing it's not pure
number nor a string.

What format is the object in that's causing the above error?

TIA

John Dalberg
 
B

Bruce Barker

select 0.5

will return a float. Int32.Parse() only supports a string. also even if you
convert to a string, Parse does not support decimal points. you can cast a
float to int. but if you are just trying to truncate:

Math.Floor((double)((DataRowView)e.Item.DataItem).Row.ItemArray[8])).ToString())

-- bruce (sqlwork.com)
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top