System.Data.Entity.Infrastructure.DbUpdateException: «Произошла ошибка при обновлении записей. Подробности смотрите во вC#

Место общения программистов C#
Ответить Пред. темаСлед. тема
Anonymous
 System.Data.Entity.Infrastructure.DbUpdateException: «Произошла ошибка при обновлении записей. Подробности смотрите во в

Сообщение Anonymous »


I post screenshot with Diagram/Generated DLL/Simple Main/And error throwing

[HttpPost] public ActionResult Add_category(tbl_category cat) { List catLi = db.tbl_category.OrderByDescending(x => x.cat_id).ToList(); ViewData["list"] = catLi; tbl_category c = new tbl_category(); c.cat_name = cat.cat_name; c.cat_fk_ad_id = Convert.ToInt32(Session["ad_id"].ToString()); db.tbl_category.Add(c); db.SaveChanges(); return RedirectToAction("Add_category"); return View(); } [HttpGet] public ActionResult Add_Questions() { int s_id = Convert.ToInt32(Session["ad_id"]); List li = db.tbl_category.Where(x => x.cat_fk_ad_id == s_id).ToList(); ViewBag.list = new SelectList(li, "cat_id", "cat_name"); return View(); } [HttpPost] public ActionResult Add_Questions(tbl_questions q) { int s_id = Convert.ToInt32(Session["ad_id"]); List li = db.tbl_category.Where(x => x.cat_fk_ad_id == s_id).ToList(); ViewBag.list = new SelectList(li, "cat_id", "cat_name"); tbl_questions qa = new tbl_questions(); qa.q_text = q.q_text; qa.QA = q.QA; qa.QB = q.QB; qa.QC = q.QC; qa.QD = q.QD; qa.QCorrectAns = q.QCorrectAns; qa.q_fk_catid = q.q_fk_catid; db.tbl_questions.Add(qa); db.SaveChanges(); ViewBag.ms = "Question Successfully Added"; return View(); } I have a problem, I have just started learning EF model-first and I'm staying in one point for some time.

I get this error :

An error occurred while updating the entries. See the inner exception for details

I have created an easy model on diagram, generated the database and wrote easy code in C# to add just one row in the table but the error is showing up all the time.


Источник: https://stackoverflow.com/questions/780 ... d-while-up
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «C#»