How to checkNull values using Execute Scalar
string strmcat = "select idcategory from categories where categorydesc='" + mcategory + "'";
SqlCommand com = new SqlCommand(strmcat, conn);
conn.Open();
Object o = (Object)com.ExecuteScalar();
if ( o != DBNull.Value)
{
idmcat = (int)com.ExecuteScalar();
}
conn.Close();
What wrong with this code.When null values return from db then also control goes in if condition.