c# - SQLDataReader Null to datetime -


having issue casting datetime reader value null.

form._date101 = reader[52] == dbnull.value ? dbnull.value : (datetime?)reader[52]; 

getting: type of conditional expression cannot determined because there no implicit conversion between 'system.dbnull' , 'system.datetime?'

any ideas?

i suspect meant:

form._date101 = reader[52] == dbnull.value ? null : (datetime?)reader[52]; 

that's assuming _date101 field of type datetime?. expect want "use null value of datetime? if value null in database; otherwise use non-null value.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -