Tags: ado, convert, datareader, datareaderitems, integer, item, itemmyreader, minus, net, netcost, numeric, value

How to convert datareader.items value to integer

On .Net » .Net ADO

457 words with 2 Comments; publish: Mon, 31 Dec 2007 17:04:00 GMT; (10060.55, « »)


I have a datareader item


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


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

How do I do it?

Thanks. Ben

All Comments

Leave a comment...

    • You can use Ctype.

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

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

      #1; Mon, 31 Dec 2007 17:05:00 GMT
    • Convert.ToInt32(myreader.Item("netcost").ToString())
      #2; Mon, 31 Dec 2007 17:06:00 GMT