這是我的code.but值不能插入數據庫中。它會通過下拉列表獲取除選定值以外的系統日期時間。引發異常「字符串未被識別爲有效的DateTime」該怎麼辦?
string strDateOfBirth = ddlMonth.SelectedValue.ToString();
strDateOfBirth = strDateOfBirth + "/" + ddlBirthDate.SelectedValue.ToString();
strDateOfBirth = strDateOfBirth + "/" + ddlYear.SelectedValue.ToString();
//objVivah.BirthDate = DateTime.ParseExact(strDateOfBirth, "MM/dd/yyyy hh:mm", null);
objVivah.BirthDate = Convert.ToDateTime(strDateOfBirth);
// objVivah.BirthDate = Convert.ToString(strDateOfBirth);
請您在第3行之後指出'strDateOfBirth'的實際值。 – 2011-05-09 05:23:26
請注意,不要發佈僅用於分散注意力的代碼。 – Oded 2011-05-09 05:29:57