0

While I am trying to insert values into the database in asp.net mvc4 with entity framework, it is throwing an exception. Help me to solve this exception.

The error message is: An error occurred while updating the entries. See the inner exception for details.

This is my code in controller

{
[HttpPost]
        public ActionResult rated(FormCollection form)
        {
            int ratedvalue = Convert.ToInt32(form["rating"]);
            using (var db = new FSLIndiaLatest.Models.FSLWebEntitiesContext())
            {
                var value = new FSLIndiaLatest.Models.Tbl_Rating();
                value.Rating = Convert.ToInt32(ratedvalue);
                value.CreatedOn = DateTime.Now;
                value.CreatedBy = 2;
                db.Tbl_Rating.Add(value);
                db.SaveChanges();
                return View(form);
            }
        }
}
Suhail Gupta
  • 22,386
  • 64
  • 200
  • 328
Vetri
  • 77
  • 2
  • 3
  • 10
  • Can you please tell what record are you getting by writing this: `var value = new FSLIndiaLatest.Models.Tbl_Rating();` – Saket Kumar Feb 20 '14 at 11:22
  • I am assigning all the table to the object. From that object i am assigning the value for table attributes. – Vetri Feb 20 '14 at 12:33

0 Answers0