473,378 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Nothing vs dbnull.value

Hi

What is the difference between Nothing and dbnull.value?

Thanks

Regards
Mar 19 '08 #1
3 5416
John wrote:
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.
Mar 19 '08 #2
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

"John" <in**@nospam.infovis.co.ukschreef in bericht
news:es**************@TK2MSFTNGP04.phx.gbl...
Hi

What is the difference between Nothing and dbnull.value?

Thanks

Regards
Mar 19 '08 #3
On Mar 18, 8:44 pm, "John" <i...@nospam.infovis.co.ukwrote:
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]
Mar 19 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Patrick.O.Ige | last post by:
When i try and use this (Where Unit is a column in my Table):- If Unit Is DBNull.Value Then Return "1" Else Return "2" End If I always have 2 returned! Even when Unit is NULL! I want a...
26
by: Bob Day | last post by:
VS 2003, vb.net, sql native (MSDE)... I have railed against the inconsistency of the Nothing key word. The documentation says is will assign a default value for any datatype...well, not...
13
by: Dune | last post by:
How do I compare a boolean with Nothing? I can't say "If boolVar Is Nothing" because a boolean is not a reference type, but "If boolVar = Nothing" always seems to return true, even if the...
8
by: MattB | last post by:
Hello. I have a vb.net (asp.net) application that uses ado.net datasets. At one point, I need to check a text field in a DataTable to see if there's any text in it before performing text operations...
6
by: tshad | last post by:
I have a value coming from my Object (or it could also be from a SqlDbReader) where I need to test for DBNull and 0. I tried to do it in one call: if (not (newPosition.ReportsTo is...
3
by: Larry | last post by:
Hi all, I am coming over from VB 6, learning VB.NET. I have read and have in front of me, the language reference from the msdn, on; Behavior of Null has changed, Isdbnull function and...
19
by: Dave | last post by:
If Iwant to check if dataset1.SelectQuery1.column1 == System.DBNull.Value. How do I do this? What I wrote above will give an error. -- L. A. Jones
12
by: xla76 | last post by:
I have a function that returns an array of string values, occasionally the returned array value is 'Nothing' I need to check if the value is nothing before moving on - how can I do this - none of...
11
by: Jethro | last post by:
Hi guys, quick sanity check please. When TESTING for nothing, it's "if <exprIs Nothing" when ASSIGNING, it's "<expr= Nothing" correct ? so a line "If ThisValue = nothing" in some...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.