日期型类型判断是否为空,空值插入和修改
DateTime PM;
if (this.txtpm.Text != "" && this.txtpm.Enabled == true)
{
PM = Convert.ToDateTime(this.txtpm.Text);
}
else
{
PM = DBNull.Value;
}
报错:Object cannot be cast from DBNull to other types.