Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have been searching for days and have attempted many, many solution without success.
I can view, create and delete rows with no problems but for some reason I am having a problem updating rows.
Any help would be great appreciated.

C#
private void cmdApproved_Click(object sender, EventArgs e)
  {
      foreach (DataGridViewRow dgr in dataGridView1.SelectedRows)
      {
          DataRow dr = workflowDataSet.tblAbm.Rows.Find(dgr.Cells[9].Value);
          if (dr != null)
          {
              dr["abmStatus"] = 5;
              dr["releasedDate"] = DateTime.Now;
               tblAbmTableAdapter.Update(workflowDataSet.tblAbm);
          }
      }
      this.tblAbmTableAdapter.GetApprovalList(this.workflowDataSet.tblAbm, Globals.gUserId);
  }
Posted
Updated 19-Feb-15 6:18am
v3

From msdn
The exception that is thrown by the DataAdapter during an insert, update, or delete operation if the number of rows affected equals zero.

So you need to see what is the UPDATE statement for the adapter. It most likely contains a WHERE clause where you'll find a condition that causes zero rows to be updated during the execution. Without seeing the UPDATE statement we can only speculate that some values in the columns used in the WHERE clause have been changed.
 
Share this answer
 
Mika,
You were correct. I set a custom update and it worked like a charm. I feel a little silly that it was that simple but appreciate you pointing me in the right direction.
 
Share this answer
 
Comments
Wendelius 19-Feb-15 23:22pm    
You're welcome. By the way, instead of adding a new solution you can leave a comment on existing solution, just like this one. By adding a comment the person who wrote the solution gets notified and knows to come back :)
Mechanic Brian 20-Feb-15 9:02am    
Thank you for that information. I missed the reply button.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900