Handling a DateTime DBNull

前端 未结 6 1914
广开言路
广开言路 2021-01-18 00:32

I have seen many, many versions of this on SO, but none of them seem to quite work for my needs.

My data comes from a vendor database that allows null for DateTime

6条回答
  •  没有蜡笔的小新
    2021-01-18 01:12

    You should use DataRow["ColumnName"] is DBNull to compare DateTime null.

    E.g.:

     if(studentDataRow["JoinDate"] is DBNull) { // Do something here }
    

提交回复
热议问题