【发布时间】:2011-10-14 10:14:18
【问题描述】:
我在 C# 程序的语句中收到以下错误消息:
dr["StartDate"] = Convert.ToDateTime(dr["business_dt"]).ToString("MM/dd/yyyy");
我在我的美国机器上没有收到此错误。但它在位于美国以外的用户机器上引发了错误。 从 datareader 返回的日期格式是:08/31/2010 12:00:00 AM
System.FormatException:字符串未被识别为有效的 DateTime。 在 System.DateTimeParse.Parse(字符串 s,DateTimeFormatInfo dtfi, DateTimeStyles 样式)在 System.Convert.ToDateTime(字符串值, IFormatProvider 提供程序)在 System.String.System.IConvertible.ToDateTime(IFormatProvider 提供程序) 在 System.Convert.ToDateTime(对象值)
请指教。
谢谢。
【问题讨论】:
-
为什么你的 DataRow 仍然包含 字符串,而不是 DateTime 值?