I have been looking for a way to evaluate if a column in a database has a null value in it. So far, every method suggested have failed and I would like to know anyone else have successfully evaluate a null value in C# Visual Studio 2005.
justapimp
1
Junior Poster in Training
Recommended Answers
Jump to PostThe following can help you but i am sure whether this is the right way.
While selecting the column check for null values like
select ISNULL(class,-1) from student
If the column class contains null values,the query returns -1 value.
Using this value you can identity the column …
Jump to PostYou need to compare the column value with System.DBNull.Value
So assuming a DataTable for example:
if( myDataTable.Rows[0]["someColumn"].Equals(System.DBNull.Value) ) { //Handle situation for null value. }
Jump to PostHmm... well it works for me. You'll have to post some code or give more information.
Jump to Postyou can also get the value of the cell and use .text.tostring
then test the length of the string len(abc) > 0
Jump to Posti converted from vb.net to c#, so it might not be accurate...
{
if (Strings.len(PID) == 0) {
}
}
All 17 Replies
bbqchickenrobot
-1
Light Poster
justapimp
1
Junior Poster in Training
ravichandra
0
Newbie Poster
hollystyles
113
Veteran Poster
justapimp
1
Junior Poster in Training
hollystyles
113
Veteran Poster
ericstenson
5
Posting Whiz in Training
Team Colleague
justapimp
1
Junior Poster in Training
ericstenson
5
Posting Whiz in Training
Team Colleague
justapimp
1
Junior Poster in Training
ericstenson
5
Posting Whiz in Training
Team Colleague
justapimp
1
Junior Poster in Training
ericstenson
5
Posting Whiz in Training
Team Colleague
hollystyles
113
Veteran Poster
justapimp
1
Junior Poster in Training
streamline
0
Newbie Poster
Kusno
0
Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.