Board index » Web Programming » Null value

Null value

Web Programming386
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.


-
 

Re:Null value

IsDBNull is to check for NULL for values coming from a DB. Here it looks

like that "theStock" is Nothing (null in C#).



Patrice



--



"wrytat" <wrytat@discussions.microsoft.com>a écrit dans le message de

Quote
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.







-

Re:Null value

Oh~ Then how do I check that if it is null in VB?



"Patrice" wrote:



Quote
IsDBNull is to check for NULL for values coming from a DB. Here it looks

like that "theStock" is Nothing (null in C#).



Patrice



--



"wrytat" <wrytat@discussions.microsoft.com>a écrit dans le message de

news:DFE85F49-1A16-4B0B-95EE-636E051D1559@microsoft.com...

>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.

>







-

Re:Null value

If (yourobject Is Nothing) Then



"wrytat" <wrytat@discussions.microsoft.com>wrote in message

Quote
Oh~ Then how do I check that if it is null in VB?



"Patrice" wrote:



>IsDBNull is to check for NULL for values coming from a DB. Here it looks

>like that "theStock" is Nothing (null in C#).

>

>Patrice

>

>--

>

>"wrytat" <wrytat@discussions.microsoft.com>a écrit dans le message de

>news:DFE85F49-1A16-4B0B-95EE-636E051D1559@microsoft.com...

>>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.

>>

>

>

>





-

Re:Null value

Quote
>IsDBNull is to check for NULL for values coming from a DB. Here it looks

>like that "theStock" is Nothing (null in C#).



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.



"wrytat" <wrytat@discussions.microsoft.com>wrote in message

Quote
Oh~ Then how do I check that if it is null in VB?



"Patrice" wrote:



>IsDBNull is to check for NULL for values coming from a DB. Here it looks

>like that "theStock" is Nothing (null in C#).

>

>Patrice

>

>--

>

>"wrytat" <wrytat@discussions.microsoft.com>a écrit dans le message de

>news:DFE85F49-1A16-4B0B-95EE-636E051D1559@microsoft.com...

>>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.

>>

>

>

>





-

Re:Null value

Ok Thanks. Actually what is the difference between null value and nothing?

Very complicated...



"MW de Jager" wrote:



Quote
If (yourobject Is Nothing) Then



"wrytat" <wrytat@discussions.microsoft.com>wrote in message

news:AD7EE332-56B5-409D-9CB8-5918C72FF090@microsoft.com...

>Oh~ Then how do I check that if it is null in VB?

>

>"Patrice" wrote:

>

>>IsDBNull is to check for NULL for values coming from a DB. Here it looks

>>like that "theStock" is Nothing (null in C#).

>>

>>Patrice

>>

>>--

>>

>>"wrytat" <wrytat@discussions.microsoft.com>a écrit dans le message de

>>news:DFE85F49-1A16-4B0B-95EE-636E051D1559@microsoft.com...

>>>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.

>>>

>>

>>

>>







-

Re:Null value

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



--



"wrytat" <wrytat@discussions.microsoft.com>a écrit dans le message de

Quote
Ok Thanks. Actually what is the difference between null value and nothing?

Very complicated...



"MW de Jager" wrote:



>If (yourobject Is Nothing) Then

>

>"wrytat" <wrytat@discussions.microsoft.com>wrote in message

>news:AD7EE332-56B5-409D-9CB8-5918C72FF090@microsoft.com...

>>Oh~ Then how do I check that if it is null in VB?

>>

>>"Patrice" wrote:

>>

>>>IsDBNull is to check for NULL for values coming from a DB. Here it

looks

>>>like that "theStock" is Nothing (null in C#).

>>>

>>>Patrice

>>>

>>>--

>>>

>>>"wrytat" <wrytat@discussions.microsoft.com>a écrit dans le message

de

>>>news:DFE85F49-1A16-4B0B-95EE-636E051D1559@microsoft.com...

>>>>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.

>>>>

>>>

>>>

>>>

>

>

>





-

Re:Null value

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.



"wrytat" <wrytat@discussions.microsoft.com>wrote in message

Quote
Ok Thanks. Actually what is the difference between null value and nothing?

Very complicated...



"MW de Jager" wrote:



>If (yourobject Is Nothing) Then

>

>"wrytat" <wrytat@discussions.microsoft.com>wrote in message

>news:AD7EE332-56B5-409D-9CB8-5918C72FF090@microsoft.com...

>>Oh~ Then how do I check that if it is null in VB?

>>

>>"Patrice" wrote:

>>

>>>IsDBNull is to check for NULL for values coming from a DB. Here it

>>>looks

>>>like that "theStock" is Nothing (null in C#).

>>>

>>>Patrice

>>>

>>>--

>>>

>>>"wrytat" <wrytat@discussions.microsoft.com>a écrit dans le message de

>>>news:DFE85F49-1A16-4B0B-95EE-636E051D1559@microsoft.com...

>>>>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.

>>>>

>>>

>>>

>>>

>

>

>





-