title: sqlbulkcopy, i want to overwrite current rows in the database
body: <p>In my program I am populating a datatable and then bulkcopying it into my database.</p>
  
  <p>However, I want it to overwrite a row in the database if 3 of the columns in the the row match.</p>
  
  <p>For example if I have 5 columns</p>
  
  <p>membernum
  dateregistered
  name
  address
  city
  state</p>
  
  <p>So if the membernum, dateregistered and name match I want to overwrite the row.
  with the data from the bulk insert. In my program the entire database table is not populated and I think its to big to load it.</p>
  
  <pre><code>Using bcp As SqlBulkCopy = New SqlBulkCopy(SqlDataSource2.ConnectionString)
  
      bcp.DestinationTableName = "dbo.dashboardtasks"
  
      bcp.WriteToServer(table)
  </code></pre>
  
  <p>If the best method is to create a datatable with my database table how would I compare the rows and then overwrite the tables where there are matches in the particular 3 columns. and then update the database with only the rows that have either changed or the new ones</p>
  
  <pre><code>INSERT INTO [dashboardtasks] ([tour], [taskname], [deptdate], [tasktype], [desc], [duedate], [compdate], [comments], [agent], [compby], [graceperiod], [id])
  </code></pre>