473,799 Members | 3,810 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Null value

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(theSto ck.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.NullRefe renceException: Object reference not set
to an instance of an object.

Nov 19 '05 #1
7 1619
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" <wr****@discuss ions.microsoft. com> a écrit dans le message de
news:DF******** *************** ***********@mic rosoft.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(theSto ck.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.NullRefe renceException: Object reference not set
to an instance of an object.

Nov 19 '05 #2
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" <wr****@discuss ions.microsoft. com> a écrit dans le message de
news:DF******** *************** ***********@mic rosoft.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(theSto ck.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.NullRefe renceException: Object reference not set
to an instance of an object.


Nov 19 '05 #3
If (yourobject Is Nothing) Then

"wrytat" <wr****@discuss ions.microsoft. com> wrote in message
news:AD******** *************** ***********@mic rosoft.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" <wr****@discuss ions.microsoft. com> a écrit dans le message de
news:DF******** *************** ***********@mic rosoft.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(theSto ck.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.NullRefe renceException: Object reference not
> set
> to an instance of an object.
>


Nov 19 '05 #4
>> 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" <wr****@discuss ions.microsoft. com> wrote in message
news:AD******** *************** ***********@mic rosoft.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" <wr****@discuss ions.microsoft. com> a écrit dans le message de
news:DF******** *************** ***********@mic rosoft.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(theSto ck.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.NullRefe renceException: Object reference not
> set
> to an instance of an object.
>


Nov 19 '05 #5
Ok Thanks. Actually what is the difference between null value and nothing?
Very complicated...

"MW de Jager" wrote:
If (yourobject Is Nothing) Then

"wrytat" <wr****@discuss ions.microsoft. com> wrote in message
news:AD******** *************** ***********@mic rosoft.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" <wr****@discuss ions.microsoft. com> a écrit dans le message de
news:DF******** *************** ***********@mic rosoft.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(theSto ck.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.NullRefe renceException: Object reference not
> set
> to an instance of an object.
>


Nov 19 '05 #6
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" <wr****@discuss ions.microsoft. com> a écrit dans le message de
news:1E******** *************** ***********@mic rosoft.com...
Ok Thanks. Actually what is the difference between null value and nothing?
Very complicated...

"MW de Jager" wrote:
If (yourobject Is Nothing) Then

"wrytat" <wr****@discuss ions.microsoft. com> wrote in message
news:AD******** *************** ***********@mic rosoft.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" <wr****@discuss ions.microsoft. com> a écrit dans le message de> news:DF******** *************** ***********@mic rosoft.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(theSto ck.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.NullRefe renceException: Object reference not> > set
> > to an instance of an object.
> >
>
>
>


Nov 19 '05 #7
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" <wr****@discuss ions.microsoft. com> wrote in message
news:1E******** *************** ***********@mic rosoft.com...
Ok Thanks. Actually what is the difference between null value and nothing?
Very complicated...

"MW de Jager" wrote:
If (yourobject Is Nothing) Then

"wrytat" <wr****@discuss ions.microsoft. com> wrote in message
news:AD******** *************** ***********@mic rosoft.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" <wr****@discuss ions.microsoft. com> a écrit dans le message de
>> news:DF******** *************** ***********@mic rosoft.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(theSto ck.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.NullRefe renceException: Object reference
>> > not
>> > set
>> > to an instance of an object.
>> >
>>
>>
>>


Nov 19 '05 #8

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

Similar topics

3
27760
by: John Morgan | last post by:
In an SQL statement which concatenates several fields I get a null value returned if any one of the fields are null. Is this to be expected? For example : SELECT tblMember.memberAddress + ' ' + tblMember.memberTown + ' ' + tblMember.memberCounty + ' ' + tblMember.memberPostCode + '<br> ' + tblMember.memberCountry + '<br> ' + tblMember.memberInstitution AS
3
7095
by: Robb Gilmore | last post by:
Hello, We have a C#.NET app which is calling a Java webservice. We use the wsdl file exportted from the java webservice to create our web-reference in Visual Studio. We are able to create the parameter classes and call the webservice just fine. Our problem is, within our .Net app, we have some value objects ( like floats, for instance ) which are meant to be null. Since there is no null float, we use float.minvalue to indicate a...
2
19350
by: PK | last post by:
Hi, I have an application that opens a Crystal report document and passes in a value to a parameter in the report (pointing to an Oracle DB). However, if I want to pass a "null" value to retrieve all records that have no data for the specified field that the parameter is a condition of (ie. SELECT * from <table> where <field> is null"), it returns nothing. I think CR is building the SQL statement like "SELECT * from <table> where <field>...
3
16607
by: Robert | last post by:
I need to be able to send a null value into a Sql Server datetime field. The follolwing code is a snippet of what I am using. I am parsing a flat file from the main frame and inserting it into a Sql DB. The "departDate can be a null value in Sql Server. I cannot figure out how to assign a null value to a SqlDateTime variable and use that variable as part of a SqlParameter, The error I keep getting is: SqlDateTime overflow. Must be...
15
29281
by: TC | last post by:
What does it mean for an integer to have a null value? I am trying to use the DataView.Find method. That method has an integer return type which contains the "index of the row in the DataView containing the sort key value specified; otherwise a null value if the sort key value does not exist." By "null value", does it mean System.DBNull? (I thought only objects could evaluate to System.DBNull.) How can I test whether an integer variable...
1
11484
by: David Shorthouse | last post by:
Hey folks, I am attempting to pass null as the input value from a series of textboxes if the user does not input a value prior to submit. To try and do this, I am using a vbscript function on this asp as follows: CommentsAdd = IIf(Request.Form("Comments")="",NULL,Request.Form("Comments")) I was hoping this would convert those emptystring textboxes to null.
7
34908
by: kumar.senthil | last post by:
Hi, I'm using XmlSerializer to create an object from the XML string. I would like to know whether I can get a null value for an empty XML element. Actually the XmlSerializer assigns "" (empty string) for a string if the corresponding element is missing in the XML. Input XML: <DemoClass><A>some value</A><B></B><DemoClass>
7
3348
by: monika varshney | last post by:
I have to read a database using dataset. My database has some null values. My code is working fine when there is a value in the database. But when there is a null value in the database, dataset throws an exception. I have to read null value in a variable. I have tried this.... if (dr != DBNull.Value) { abc = Convert.ToDouble(dr); MessageBox.Show("value is:" +...
0
3070
prabirchoudhury
by: prabirchoudhury | last post by:
CRITERIA; +-------------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------------+--------------+------+-----+---------+-------+ | CritCode | int(4) | NO | PRI | 0 | | | Description | varchar(150) | YES | | NULL | | | CritGroup | varchar(10) | YES | | NULL | | | Detail | varchar(30) | YES | | NULL | ...
2
14664
by: qwedster | last post by:
Folk! How to programattically check if null value exists in database table (using stored procedure)? I know it's possble in the Query Analyzer (see last SQL query batch statements)? But how can I pass null value as parameter to the database stored procedure programattically using C#? Although I can check for empty column (the following code passes string.Empty as parameter but how to pass null value?), I cannot check for null value...
0
10488
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10257
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10237
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10029
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9077
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.