I have a question about this Keith ... what are you doing with the data once you're done with it on the UI side ... AFAIK, you can't send Nothing (or null in C#) back to the Database. Actually, I've discovered that you can't send DBNull back to the Database either (at least not SQL Server), but that's another story. <g>
I don't really see a good reason to cast DBNull to Nothing though ... what does that give you? You still need to test for Nothing, don't you? DBNull and Nothing mean different things, one is a NULL value in a database column, the other means basically that an object hasn't been instantiated ... so, I'm just curious about how you're utilizing this. Maybe I'm missing something useful. <g>
I wrote a function that returns a specified default if you pass it a DBNull, so I can say
GetNonNull(row["MyColumn"], "") and it will return whatever's in MyColumn unless it's DBNull and then it will return "". The function is overloaded so that if the datatype I pass it is numeric, I can return a zero, or if I pass a date column, it can return a specified date, etc.
~~Bonnie
>I have another one:
>
>.NET does not automatically cast DBNull to Nothing, so I wrote a nvl() function that flip-flops between DBNull and Nothing. Now my code is full of calls to this function!
>
>There might be a valid reason why .NET does not do this, but I have yet to come across a scenario where I could see that it would be a problem.