|
it
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Casting tinyint and smalling columns
Hello all,
I'm working on an application that uses a DbDataReader to retrieve information from a SQL Server 2005 column, then put that data into object variables. My code looks like this: value = (int)dbReader["value"] For column types of int, this works fine. However, for tinyint or smallint, I get an invalid cast error. Is there a way to make this work? Thanks, Jacob Hello Jacob,
For .NET related issue, you may post in microsoft.public.dotnet.general or microsoft.public.dotnet.framework.adonet. Regarding the question, you may try DbDataReader's GetInt32() method to convert a column's value to integer. Regards, Luke Zhang Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== (This posting is provided "AS IS", with no warranties, and confers no rights.) |
|||||||||||||||||||||||