於Allen功課 VerifySystemDB執行新增表單時
db.SaveChanges();
會報錯
[HttpPost]
publicActionResult Create(CheckForm checkform)
{
if (ModelState.IsValid)
{
db.CheckForm.Add(newCheckForm(){
Applicants = checkform.Applicants,
//ApplyDate = checkform.ApplyDate, 配合資料庫預設getdate會有問題
ApplyDate = DateTime.Now,
ApplyContent = checkform.ApplyContent,
Project = checkform.Project,
Reviewer = checkform.Reviewer});
db.SaveChanges();
return RedirectToAction("Index");
}
return View(checkform);
雖然資料輸入都是正確的,但還是有問題
Joe幫忙嘗試改寫為DateTime.Now後可正常輸入
根據Joe經驗 資料庫預設GetDate()偶爾會有問題要注意