DataReader question - Sql datatypes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Guest's Avatar

    DataReader question - Sql datatypes

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

    SqlDr.GetInt16( MyTinyIntColumn Ordinal) fails and causes a
    InvalidCastExce ption. Thanks for your help.
  • Ignacio Machin \( .NET/ C#  MVP \)

    #2
    Re: DataReader question - Sql datatypes

    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,

    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation

    <anonymous@disc ussions.microso ft.com> wrote in message
    news:1999701c41 cc3$3fb5dc60$a4 01280a@phx.gbl. ..[color=blue]
    > Hi all
    > My datareader reads a tinyint SQL column. How do I
    > retrieve the value of the column.
    >
    > SqlDr.GetInt16( MyTinyIntColumn Ordinal) fails and causes a
    > InvalidCastExce ption. Thanks for your help.[/color]


    Comment

    Working...