Click to See Complete Forum and Search --> : problem with tinyint when getValue


raulbolanos
July 1st, 2009, 03:44 AM
Hello guys,

Do you know why I get an error message when I try to get one value from a specific column when the datatype of this value is 'tinyint'?

If I change it to 'int' I dont get any error.


int valueX = (int)dataReader.GetValue(1));


Thank you in advance.

boudino
July 1st, 2009, 04:23 AM
What exactly is the error message?

Grofit
July 1st, 2009, 04:59 AM
tinyint is type Byte i believe... 0-255

So when you try to copy it into the int although it should be a perfectly valid assignment as there is no specific cast i think it eats its own face then cries in the corner of the room... you can always do Convert.ToInt32(), or change your int to a byte as it will only ever get values from 0-255 i think... or -128-128...