How to get nullable DateTime out of the database

后端 未结 7 1522
滥情空心
滥情空心 2020-12-01 18:04

My SQL Server database contains nullable DateTime values. How can I convert them to a nullable DateTime object in my application in C#?

This is what I would think it

7条回答
  •  猫巷女王i
    2020-12-01 18:49

    I recently found this trick, it's simple:

    DateTime? dt = sqldatareader[0] as DateTime?;
    

提交回复
热议问题