我不明白我在哪里犯了这个错误 System.FormatException: 'String was not recognized as a valid DateTime'UserDOB 工作正常,但 DateTimeStamp 不工作。while (reader.Read()){ list1.Add(new User() { UserId = Convert.ToInt32(reader["UserId"]), UserName = reader["UserName"].ToString(), UserSurname = reader["UserSurname"].ToString(), UserPassportNo = reader["UserPassportNo"].ToString(), UserAccessPoint = reader["UserAccessPoint"].ToString(), UserAccessType = reader["UserAccessType"].ToString(), UserDOB = DateTime.Parse(reader["UserDOB"].ToString()), DateTimeStamp = DateTime.Parse(reader["DateTimeStamp"].ToString()), });}我的model.DatabaseConnectionpublic class User{ public int UserId { get; set; } public string UserName { get; set; } public string UserSurname { get; set; } public string UserPassportNo { get; set; } public string UserAccessPoint { get; set; } public string UserAccessType { get; set; } public System.DateTime UserDOB { get; set; } //[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/dd/yyyy}")] public System.DateTime DateTimeStamp { get; set; }}
1 回答
- 1 回答
- 0 关注
- 123 浏览
添加回答
举报
0/150
提交
取消