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:
' Save Records Private Sub SaveRecords() If ds.HasChanges() Then Dim da As SqlDataAdapter = Nothing Dim cb As SqlCommandBuilder = Nothing da = New SqlDataAdapter("Select " & _ "PosiPayID, " & _ "TranType, " & _ "TranDate, " & _ "TranAmt, " & _ "TranDesc, " & _ "RefNbr, " & _ "Processed " & _ "FROM PosiPay.dbo.PosiPayTransactions " & _ "Order by RefNbr", Con) da.TableMappings.Add("Table", "PosiPay") Try Try ExportDS(ds) Catch ex As Exception MessageBox.Show(ex.Message) End Try cb = New SqlCommandBuilder(da) da.Update(ds) MessageBox.Show("Changes Saved", _ "Success", _ MessageBoxButtons.OK) Catch ex As Exception MessageBox.Show(ex.Message & vbNewLine & _ ex.Source & vbNewLine & _ ex.StackTrace, "Save Change Error", _ MessageBoxButtons.OK) Finally cb.Dispose() da.Dispose() End Try Else Exit Sub End If End Sub




Reply With Quote