Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Pet Peeves with .NET
Message
From
28/12/2003 10:00:36
 
 
To
28/12/2003 00:38:28
Keith Payne
Technical Marketing Solutions
Florida, United States
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00830196
Message ID:
00862343
Views:
17
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.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform