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,
 

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

Back
Top