[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 8263
  • Last Modified:

check if a DataRow cell is null

i want to check if a datarow cell has anything in it.

if it is null - i will put a string.empty into it(i think this is best)

i am doing this so i can just populate a address object without worrying if it will break because the data cell is null.

my code which didnt work is:
//check address for nulls

if (dr["Postcode"] = null)
{
dr["Postcode"] = s;
}
0
MrKevorkian
Asked:
MrKevorkian
1 Solution
 
Mohammad Aamir QureshiCommented:
plz give me more explanation
0
 
MrKevorkianAuthor Commented:
i collect a dataset from the db.

i want a way of checking if its datarows contents contain any data or if they are null

if they are null then just assign a default empty string

 
0
 
AgariciCommented:
you should check against 'DBNull.Value' not 'null'
or use DataRow.IsNull( "column name" )

hth,
A.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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