I'm puzzled as to what cast in C# to make for a query to T-SQL that returns a tinyint
.
Using a SqlDataReader
...
int Precision = 0;
SqlDataReader reader = myCommand.ExecuteReader();
if (reader.Read())
{
Precision = reader.GetInt16(0);
}
I'm getting an InvalidCastException
when I use GetInt16
, and that's the smallest integer cast apparently available. In the same code I successfully cast a smallint
to int16
.
What Get....
do I use for tinyint
?
Edited to add:
An answer which was subsequently deleted said to use GetByte
. I did, and that worked.