抱歉,但这是脑电波。我已经搜索了整个互联网,但还是找不出答案。
错误:“无法将'System.DateTime‘类型的对象转换为’System.String‘。”
if (oDbDataReader.GetString(2) == DateTime.Now.AddDays(-90).ToShortDateString()) //DateCreated
{
oEmp.PasswordCompliance = "Password expired";
}发布于 2012-07-12 22:07:44
第2栏的类型是什么?如果是DateTime,您应该尝试DbDataReader.GetDateTime
if (oDbDataReader.GetDateTime(2) < DateTime.Now.AddDays(-90))
{
oEmp.PasswordCompliance = "Password expired";
}https://stackoverflow.com/questions/11461390
复制相似问题