我们如何从中读取整数空值SqlDataReader
?
CREATE TABLE [dbo].[Mem_Basic] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[Mem_Email] VARCHAR (50) NULL,
[Mem_DOB] DATE NULL,
[Mem_ResPin] INT NULL,
PRIMARY KEY CLUSTERED ([Id] ASC)
);
对于我使用的字符串和整数
if (reader.Read() == true)
{
mb.Mem_Email = reader["Mem_Email"] == System.DBNull.Value ? null : (string)reader["Mem_Email"];
mb.Mem_ResPin = reader["Mem_ResPin"] as int? ?? default(int);
}
但是我如何以同样的方式从读者那里读取日期?
//mb.Mem_DOB = (Convert.ToDateTime(reader["Mem_DOB"]));