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()偶爾會有問題要注意

arrow
arrow
    文章標籤
    問題經驗
    全站熱搜
    創作者介紹
    創作者 JayeChen987 的頭像
    JayeChen987

    Jaye的碎碎念

    JayeChen987 發表在 痞客邦 留言(0) 人氣()