Edit: Just to be clear, I'm not asking about (Null
vs DBNull.Value
) or (IsDBNull
vs IsNull
).
Well, I always use IsDBNull()
to evaluate database fields and check if the value is DBNull
, but I noticed that in many code examples, people use DBNull.Value
for the same purpose. Here's how:
If IsDBNull(obj) Then DoSomething() ' ---> My approach
If obj = DBNull.Value Then DoSomething() ' ---> Theirs.
Also in C#:
if (obj == DBNull.Value) {DoSomething();}
I did some search to find out if they're the same or if there's any difference between them, but can't find any useful articles that show these two particular evaluation approaches together.
This MSDN link demonstrates how DBNull.Value.Equals
does the same thing as IsDBNull
function, but never mentions/suggests using DBNull.Value
for evaluation, without the use of Equals
function.
So, I'm really wondering, is there any actual difference between these two so that one of them is recommended over the other? Or do they do the exact same thing?