Null value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I check if an object is null in vb? I tried using IsDBNull but it
doesn't work at all. It gives me this error when I try statement like If Not
IsDBNull(theStock.WIPQty) Then:

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
 
IsDBNull is to check for NULL for values coming from a DB. Here it looks
like that "theStock" is Nothing (null in C#).

Patrice
 
IsDBNull is to check for NULL for values coming from a DB. Here it looks
Oh~ Then how do I check that if it is null in VB?

ROFLMOD!

Never mind. It's Nothing.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.
 
Ok Thanks. Actually what is the difference between null value and nothing?
Very complicated...
 
NULL in a database means that the value is not "defined" (i.e. if the price
column for the product is NULL the price is not known, 0 would mean it is
free). This is called DBNull in .NET.

"Nothing" (null in C#) means that the object doesn't exist... (basically
objects are pointers, it means that this pointer is not yet defined).

Patrice

--
 
The difference between null and Nothing is the language you're coding in.
"null" is C# for "Nothing" in VB, which is "nada" in Espanol. However,
Espanol is not a programming language. ;-)

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Sometimes you eat the elephant.
Sometimes the elephant eats you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top