Help dealing with nulls.

Posted on 2007-10-10
Last Modified: 2010-04-23
I am trying to figure out the cleanest way to do something
If I am adding rows to a datatable like below, what is the best way to assign a zero if a value in the row is null?

While dr.Read
                newrow = dt.NewRow
                newrow("Unit") = dr("Unit")
                newrow("One") = dr("One")
                newrow("DT") = dr("DT")
            End While
Question by:NickMalloy
    1 Comment
    LVL 142

    Accepted Solution

    why not use a COALESCE()  or corresponding function in the query directly?

    anyhow, you might get inspired from the following code:

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now