[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Checking for null value?

Posted on 2008-01-28
5
Medium Priority
?
214 Views
Last Modified: 2010-04-15
Hello all.  How do I ensure that if a dataset field is null I dont want to try and set it?  I thought it was just != null but that is not working.  However, I could swear that works in the later frameworks.  In 1.1 I have the following which the field is null but it still gets into the next line of code:

if (dsOrderDetail.Tables[0].Rows[0]["OrderTotal"] != null)
{  //field is null but it still gets into this code
}
0
Comment
Question by:sbornstein2
5 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 2000 total points
ID: 20765425
you can do as:

if (!Convert.IsDBNull(dsOrderDetail.Tables[0].Rows[0]["OrderTotal"])
{
}
0
 
LVL 7

Expert Comment

by:AUmidh
ID: 20765437
if (equals(dsOrderDetail.Tables[0].Rows[0]["OrderTotal"],Dbnull.value)!=true)
{  
}
0
 

Author Comment

by:sbornstein2
ID: 20765444
do you know if what I had here works possibly in the later versions?
0
 
LVL 9

Expert Comment

by:Rahul Goel ITIL
ID: 20765613
if (!Convert.IsDBNull(dsOrderDetail.Tables[0].Rows[0]["OrderTotal"])
{
}
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20767312
@Rahu,
have you read the previous answers?
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Free Data Recovery software is an advanced solution from Kernel Tools to recover data and files such as documents, emails, database, media and pictures, etc. It supports recovery from physical & logical drive after a hard disk crash, accidental/inte…
Suggested Courses

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question