我在我的controller.this代碼給出了一個異常,當我試圖通過DataSet循環。異常是在不同的行當我運行時(例外情況並非發生在確切的行)C# - 「字符串未被識別爲有效的日期時間」異常
例外是;
字符串未被識別爲有效的DateTime。
DateTime arrDate = DateTime.Parse(ds.Tables[0].Rows[i]["CheckInDate"].ToString());
我想這太;
DateTime createdDate = DateTime.ParseExact(ds.Tables[0].Rows[i]["CheckInDate"].ToString(), "MM/dd/yyyy HH:mm", CultureInfo.InvariantCulture);
,但還沒有成型..
該行的值是2/9/2016 21:20
您傳遞的CheckInDate的值是多少?我們需要先看看。如果它是'dateimte'字段,則可以在不解析的情況下投射到'DateTime'。 – Lloyd
我的猜測是字符串不是有效的日期時間....?! – Liam
@Lloyd Strings like 2/9/2016 21:20 .. –