Check dbnull in C# as per Bellow.
String Example
string name = dr["name"] ==
DBNull.Value ?
"1" : dr["name"].ToString(); Integer example
int name = dr["name"] == DBNull.Value ? "1" : dr["name"].ToString();
You can also Check Like Bellow
if (string.IsNullOrEmpty(Convert.ToString(Dr["Name"]))) {
}
or
if (System.DBNull.Value == Dr["Name"]) {
} .
Check dbnull in VB.Net as per Bellow.
IIf(IsDBNull(dr("name")), "1",dr("name")))
No comments:
Post a Comment