Using the BackgroundWorker to transfer data between databases

  • Thread starter Thread starter AndyNakamura
  • Start date Start date
A

AndyNakamura

Guest
I need to copy the data from an old database to a new one.
There are three tables.

I have the code for doing that but I'd like to show a progress bar to indicate that something is happening.
Pseudo Code:
For each record in old Table1
Write to new table1
Data1Transfered = Data1Transfered + 1
worker.ReportProgress(Data1Transfered)
Next
For each record in old Table2
Write to new table2 Data2Transfered = Data2Transfered + 1
worker.ReportProgress(Data2Transfered)
Next
For each record in old Table3
Write to new table3 Data3Transfered = Data3Transfered + 1
worker.ReportProgress(Data3Transfered)
Next

Then I have a label to display the count of records as they are transferred.

Private Sub BackgroundWorker1_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
Label1.Text = e.ProgressPercentage.ToString
End Sub


Which is ok, but they all go into label1. I'd like to use three labels, one for each table.
Do I need to use three background workers?
Also, as table3 depends on values being present in table1 & 2 it is important that the finish before populating table3 starts.
Also (Lots of Alsos) I only seem to have the choice of e.ProgressPercentage even though I only want a count.

Clearly this is the first time I've tried to use the background worker.

Any help appreciated.

Andy

Continue reading...
 
Back
Top