Is there any difference between null and System.DBNull.Value? If yes, what is it?
I noticed this behavior now -
while (rdr.Read())
{
if (rdr[\"I
DBNull.Value is annoying to have to deal with.
I use static methods that check if it's DBNull and then return the value.
SqlDataReader r = ...;
String firstName = getString(r[COL_Firstname]);
private static String getString(Object o) {
if (o == DBNull.Value) return null;
return (String) o;
}
Also, when inserting values into a DataRow, you can't use "null", you have to use DBNull.Value.
Have two representations of "null" is a bad design for no apparent benefit.