• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

Help dealing with nulls.

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")
                dt.Rows.Add(newrow)
            End While
0
NickMalloy
Asked:
NickMalloy
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
why not use a COALESCE()  or corresponding function in the query directly?

anyhow, you might get inspired from the following code:
http://www.mredkj.com/vbnet/FixNull.html
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now