看看这篇文章
http://msdn.microsoft.com/en-us/library/w2sa9yss.aspx
要看的关键部分是
// Parse date-only value without leading zero in month using "d" format.
// Should throw a FormatException because standard short date pattern of
// invariant culture requires two-digit month.
dateString = "6/15/2008";
try {
result = DateTime.ParseExact(dateString, format, provider);
Console.WriteLine("{0} converts to {1}.", dateString, result.ToString());
}
catch (FormatException) {
Console.WriteLine("{0} is not in the correct format.", dateString);
}
因此,您的数据库可能没有返回标准模式。对我来说似乎很愚蠢,但这会引发异常。在这个例子中,它只是说一个“仅限日期”的值,而你的不是。
如果您在字符串中有日期,则可以进行旧的手动修复:
public static string FixDate(string date)
{
return (date.IndexOf('/') == 1) ? "0" + date : date;
}