Geeks With Blogs
Jim Lahman's Blog Fortitude|Endurance|Faith|Teamwork

If the column you are reading has the potential for a NULL value, then you must use the DBNull object:


DataRowView dRowView = m_SchedCommentsBindingSource[0] as DataRowView;

dsL2DB.SchedulesRow SchedRow = dRowView.Row as dsL2DB.SchedulesRow;

sDeleteComment = (SchedRow["DeleteComment"] == DBNull.Value ? "No Delete Comment" : SchedRow.DeleteComment);

 

More generically:

 

If (ds.Rows[0]["ColumnName"] == DBNull.Value)

{

// Do something for NULL value

}


Posted on Tuesday, May 26, 2009 5:04 PM | Back to top


Comments on this post: C# - Checking for NULL

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Jim Lahman | Powered by: GeeksWithBlogs.net