DataReader question - Sql datatypes

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all
My datareader reads a tinyint SQL column. How do I
retrieve the value of the column.

SqlDr.GetInt16(MyTinyIntColumnOrdinal) fails and causes a
InvalidCastException. Thanks for your help.
 
Hi,

The data types in SQL & .NET do not usually match , you can use
Convert.ToInt16().

tinyint is defined in SQL as a 8 bit data, therefore GetInt16() give you
error, you should use GetByte() instead.

Cheers,
 
Back
Top