Nothing vs dbnull.value

  • Thread starter Thread starter John
  • Start date Start date
John,

Null tells that there is nothing as the reference to an object (in VB what
is not Ecla is using the keyword as it is "Nothing")
DBNull.Value is a value type (used as a database can return an empty value
and then returns that type)

Both are a kind of legacy from the past. By instance Intel based computers
initialize the declared memory with nulls char(00), other computers do that
with high values char(255). So "null" comes from the hardware and is
practicaly the use of a very low based program language as original C in
fact was. Let say as that we woud use AR for adding two fields (Add
Register) as it was in the beginning even before C.

Cor
 
Hi

What is the difference between Nothing and dbnull.value?

Thanks

Regards

As Steve has said, Nothing is basically a state of an object
reference. The reference is either pointing to something or nothing,
so when you are checking for 'is nothing' you are not looking at a
value of an object, but rather it's state. DbNull on the other hand,
does not refer to a state, but a value of an object. Nullable columns
have to be treated special by the database, and that fact must be
handled by .NET. When you receive a value from a database the
reference is pointing to a value, that value being DbNull.

The good news is, that most times you can forgo the search for DbNull.
Especially if you are using a datareader to pull the data, you can
simply do datareader("ColumnName").ToString() and .NET will convert a
DbNull into a blank string ""

Thanks,

Seth Rowe [MVP]
 
Back
Top