title: How do I update DatabaseDataSet using TableAdapter?
body: <p>I'm using Visual C# Studio 2010 express and have been trying to batch update my table. Everytime that I try to update 1 record I get "Concurrency violation: the UpdateCommand affected 0 of the expected 1 records."  I asked this question at dream in code but I have been a little dissapointed in some of the responses to some honest questions. <a href="http://www.dreamincode.net/forums/topic/274690-concurrency-violation-while-trying-to-update-database/" rel="nofollow">Link to my question at D.I.C</a></p>
  
  <p>I took that last suggestions and changed my code to affect the dataset..or so I think but i am getting the concurrent issue still. Here is my updated code.</p>
  
  <pre><code>        private void SendNewPotentialsToZoho()
      {
          Console.WriteLine("Trying to send potentials to Zoho");
  
          var newZoho = potentialDatabaseDataSet.Potential.DefaultView;
          var poster = new ZohoPoster(ZohoPoster.Fields.Potentials, ZohoPoster.Calls.insertRecords);
          var count = 0;
  
          //newZoho.RowFilter = "IsNull(ZohoID,'zoho') = 'zoho'";
          newZoho.RowFilter = "Soid = 1234";
          poster.Debugging = !UseZoho;
          for (int i = 0; i &lt; 1; i++)//newZoho.Count; i++)
          {
              var xmlString = Potential.GetPotentialXML(newZoho[i][1], newZoho[i][2], newZoho[i][4], newZoho[i][3], newZoho[i][5], newZoho[i][7], newZoho[i][0]);
              Console.WriteLine("Sending New Records to Zoho: {0}", xmlString);
              poster.PostItem.Set("xmlData", xmlString);
              var result = poster.Post(3);
              Console.WriteLine(result);
              if (!string.IsNullOrEmpty(result))
              {
                  try
                  {
                      var rowLength = newZoho[i].Row.ItemArray.Length;
                      var rowOffset = Math.Abs((int)newZoho[i][rowLength - 1])-1;
  
                      potentialDatabaseDataSet.Potential.Rows[rowOffset]["ZohoID"] = ReadResult(result);
                      potentialTableAdapter.Update(potentialDatabaseDataSet.Potential.Rows[rowOffset]);
                  }
                  catch (Exception ex)
                  {
                      Console.WriteLine("Failed to update: {0}", ex.Message);
                  }
              }
          }
      }
  </code></pre>
  
  <p>The bit variable called poster works great. it returns a xml like result that has my zohoID which I parse out and try to store. For testing purposes I try to update only one record. I get the error with potentialTableAdapter.Update(potentialDatabaseDataSet). What is strange to me is that I use a very similar code to make a brand new record and it works great. Infact it is how I made the row with Soid = 1234. I am the only one that has access to this program and as far I know it is not multithreaded so I just don't understand why it is having concurrency issues. Please help :)</p>
  
  <p><em>EDIT</em></p>
  
  <p>Ok so I was playing around with it some and found that if I add a EndEdit to it I dont get the concurrent issue. On the flip side though Although my bound datagridview shows the updated data, the data doesn't actually get updated. So it's not that i'm back to square one I think i am actually rather close. I'm going from memory on this small bit of code so don't hate if it isn't right..it's mainly for an idea of what i'm talking about</p>
  
  <pre><code>        for (int i = 0; i &lt; 5; i++) //emailRecord.Count; i++)
          {
              if (ZohoEmail.EmailExpectedShipping(emailRecord[i], "12/10/2012"))
              {//true means that the email went through just fine
                  try
                  {
                      var rowLengh = emailRecord[i].Row.ItemArray.Length;
                      var rowOffset = Math.Abs((int)emailRecord[i][rowLengh - 1]) - 1;
  
                      potentialDatabaseDataSet.Potential.Rows[rowOffset][17] = true; //17 is Expected Email
                      potentialDatabaseDataSet.Potential.Rows[rowOffset].AcceptChanges();
                  }
                  catch (Exception ex)
                  {
                      Console.WriteLine("Failed to update: {0}", ex.Message);
                  }
              }
              potentialTableAdapter.Update(potentialDatabaseDataSet.Potential);
          }
  
      }
  </code></pre>