TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
athira k
NA
140
53.5k
Why It showing error in modifying db in mvc in edit action
May 9 2017 2:53 AM
I have a confution in my project that when I am modifying the data to db it shows the error that "
Store update, insert, or delete statement affected an unexpected number of rows (0). Entities may have been modified or deleted since entities were loaded. See http://go.microsoft.com/fwlink/?LinkId=472540 for information on understanding and handling optimistic concurrency exceptions."
I am getting the value which I needed in the HttpPost of edit action method, the error arise only when saving it to the db
controller
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Edit( StudentDetail studentDetail )
{
if (ModelState.IsValid)
{
studentDetail .CashInHand -= studentDetail .CashReceived;
studentDetail .Amount += studentDetail .CashReceived;
studentDetail .Date = DateTime.Now;
studentDetail .cashReceived = null;
db.Entry(studentDetail ).State = EntityState.Modified;
await db.SaveChangesAsync();
return RedirectToAction("Index");
}
return View(studentDetail );
}
I am getting details in studentDetail. Then Why is that the error showing ???can anyone please help me to find the solution ??
Reply
Answers (
4
)
how to insert label value in database
How to add scroll bar on asp.net page using jquery