Saturday, December 27, 2008

How To: Check a null value in a column of a DataTable in a DataSet

This article will show some ways of checking for null values in a DataTable
Here are a couple of ways to check for nulls in a column
VB.NET
If Convert.IsDBNull(ds.Tables(0).Rows(0)("Code")) Then End If
OR
If ds.Tables(0).Rows(0)("Code") Is DBNull.Value Then End If
C#
if (Convert.IsDBNull(ds.Tables[0].Rows[0]["Code"])){ }
OR
if (ds.Tables[0].Rows[0]["Code"] == DBNull.Value){ }
window.google_render_ad();

No comments: