Monday, March 12, 2012

How to convert datareader.items value to integer

Hi,

I have a datareader item

myreader.Item("netcost")

This is a numeric value, I need to take the value and minus 500 from it, I have

(myreader.Item("netcost")-500)

This causes an error, 'cannot cast from string to integer'

How do I do it?

Thanks. BenYou can use Ctype.

For example, this converts you datareader item to an integer.

CType(myreader.Item("netcost"),Integer) - 500
Convert.ToInt32(myreader.Item("netcost").ToString())

Labels: , , , , , , , , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home