Hi
>
What is the difference between Nothing and dbnull.value?
>
The important thing is that they are not the same.
Nothing generally refers to an object reference variable that is not a reference
to anything, that is, does not refer to any object.
DBNull.Value is not an object reference, but indicates that a value is Null. As
its name suggests, it usually means that in a database, that particular column,
in some particular row, is Null, even if the column is say an integer column. It
applies to values, not object references.
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
"John" <info@nospam.in fovis.co.ukschr eef in bericht
news:eswObpViIH A.5968@TK2MSFTN GP04.phx.gbl...
Hi
>
What is the difference between Nothing and dbnull.value?
>
Thanks
>
Regards
>
On Mar 18, 8:44 pm, "John" <i...@nospam.in fovis.co.ukwrot e:
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("Col umnName").ToStr ing() and .NET will convert a
DbNull into a blank string ""
Comment