title: DataAdapter Update not properly Inserting data into SQL Server?
body: <p>I have 2 <code>DataTables</code>: 1 that is filled with all the data from a table in my database called <code>Ticket_Report</code>, and a second one that is filled with new tickets.</p>
  
  <p>I am searching the <code>Ticket_report</code> datatable for duplicates from the new ticket DataTable (and deleting them). Then I merge the new tickets datatable into the <code>Ticket_report</code> datatable.</p>
  
  <p>I then try and Update the Ticket_Report table in SQL Server with the newly edited <code>Ticket_report</code> datatable. I am expecting the Update method to Update the table in SQL Server with rows that have matching primary keys from the datatable, and Insert rows that don't exist.</p>
  
  <p>I am not getting any errors, however it doesn't seem like the rows are being updated/inserted.</p>
  
  <pre><code>con.Open();
  DataTable ticketReportDT = new DataTable();
  ticketReportDT = newTicketdt.Clone();
  ticketReportDT.Columns[0].Unique = true;
  
  SqlCommand cmd2 = new SqlCommand("SELECT * FROM ticket_report", con);
  SqlDataAdapter da = new SqlDataAdapter(cmd2);
  
  da.Fill(ticketReportDT);
  da.UpdateCommand = new SqlCommandBuilder(da).GetUpdateCommand();
  
  int currentTicketCount = ticketReportDT.Rows.Count;//3234
  int newTicketCount = newTicketdt.Rows.Count; //339
  
  //Removing Duplicate tickets in ticketReportDt
  foreach (DataRow NewTicketsRow in newTicketdt.Rows)
  {
     foreach (DataRow currentTicketsRow in ticketReportDT.Select())
      {
          if (currentTicketsRow.Field&lt;string&gt;(ticketReportDT.Columns[0]) == NewTicketsRow.Field&lt;string&gt;(newTicketdt.Columns[0]))
          {
              currentTicketsRow.Delete();
          }
      }
  }
  
  ticketReportDT.AcceptChanges();
  int currentTicketCount2 = ticketReportDT.Rows.Count;//2903, is less than last count because duplicates removed
  
  ticketReportDT.Merge(newTicketdt);//add new tickets to ticketReportDT
  ticketReportDT.AcceptChanges();
  
  int currentTicketCount3 = ticketReportDT.Rows.Count;//3242, count went up because new tickets added
  
  da.Update(ticketReportDT);//apply changes to database table Ticket_Report
  con.Close();
  Console.WriteLine("Ticket Transfer Complete");
  </code></pre>
  
  <p>This runs without error. To test, I did a count query in SQL Server before and after this update.</p>
  
  <p>Before update: </p>
  
  <pre><code>select count(*) from TICKET_REPORT
  // = 3234
  </code></pre>
  
  <p>After Update:</p>
  
  <pre><code>select count(*) from TICKET_REPORT
  // = 3234 &lt;-Should be 3242 (row count of ticketReportDT)
  </code></pre>
  
  <p>It seems like the Datatable has the correct amount of rows, but when I do the update, this does not reflect in SQL Server. Am I doing something wrong?</p>