I want to export only the changed data in my dataset. There is another sub that loads the dataset when the form loads. This (sub below) is ran when the user closes the form. It updates the table with any changed values. I would like to catch all the records that have changed in the dataset and export them to a csv file. I already have the export part figured out but the way it is now it is exporting the entire dataset and not just the changed rows.
VB Code:
  1. ' Save Records
  2.     Private Sub SaveRecords()
  3.         If ds.HasChanges() Then
  4.             Dim da As SqlDataAdapter = Nothing
  5.             Dim cb As SqlCommandBuilder = Nothing
  6.             da = New SqlDataAdapter("Select " & _
  7.                 "PosiPayID, " & _
  8.                 "TranType, " & _
  9.                 "TranDate, " & _
  10.                 "TranAmt, " & _
  11.                 "TranDesc, " & _
  12.                 "RefNbr, " & _
  13.                 "Processed " & _
  14.                 "FROM PosiPay.dbo.PosiPayTransactions " & _
  15.                 "Order by RefNbr", Con)
  16.             da.TableMappings.Add("Table", "PosiPay")
  17.             Try
  18.                 Try
  19.                     ExportDS(ds)
  20.                 Catch ex As Exception
  21.                     MessageBox.Show(ex.Message)
  22.                 End Try
  23.                 cb = New SqlCommandBuilder(da)
  24.                 da.Update(ds)
  25.                 MessageBox.Show("Changes Saved", _
  26.                                 "Success", _
  27.                                 MessageBoxButtons.OK)
  28.             Catch ex As Exception
  29.                 MessageBox.Show(ex.Message & vbNewLine & _
  30.                                 ex.Source & vbNewLine & _
  31.                                 ex.StackTrace, "Save Change Error", _
  32.                                 MessageBoxButtons.OK)
  33.             Finally
  34.                 cb.Dispose()
  35.                 da.Dispose()
  36.             End Try
  37.         Else
  38.             Exit Sub
  39.         End If
  40.     End Sub