sql data type bit
I have sql data type bit and i want to ask
if(dr[2] != null开发者_StackOverflow中文版)
What changes should make it? Sorry for the mistakes I'm not local.
To check if the column value is NULL, use DBNull.Value:
if (dr[2] != DBNull.Value)
Assuming dr is a DataReader, calling dr.IsDBNull(2) will tell you whether it's null.
I wrote like this and the value is NULL dr[2] != System.DBNull.Value and this answer Object cannot be cast from DBNull to other types.
精彩评论