![]() |
How to retrieve nullable data from a MS SQL server database by using a DataReader
Hey guys,
I have a question about selecting data from a MS Sql server database by using a SqlDataReader. The problem is that some of the columns in my table can be null. I want to retrieve a bool value or a null depending on what is in the column. I tried using the bool? type like this: :
it compiles, but throws an Invalid Cast exception at runtime if the value in the "ConfirmColumn" is NULL. Has any of you had the same problem to solve? Any ideas? Thanks in advance. |
What is spam? And what is edit?
|
Hi,
I believe this is what you need :
I am better with VB .NET so i tried converting it over to C#, one thing to watch out for, I wasn't sure whether or not to use "is" or "==", in VB .NET you use "is" when working with potential null conditionals, wasn't sure if C# was the same or not. so you may need to change it if it doesn't work. try this first though. good luck |
thank you melbolt - it is a good idea
|
| All times are GMT -5. The time now is 2:23 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC