Note that there are some explanatory texts on larger screens.

plurals
  1. POvb.net 4 threads to fill the same database
    primarykey
    data
    text
    <p>Hello i've a loop that last about 2 hours to finish, it gets the data from internet and fills it to a database so i want to divide it to 4 threads, and i am trying to do some testing before i put this to my application.</p> <p>so here is a sample that i wrote to fill one database by 4 threads and i am getting this error "BindingSource cannot be its own data source"</p> <pre><code> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.DataGridView1.DataSource = Me.bindingSource1 GetData("select * from products") End Sub Public Sub thread1f0() For i = 0 To 500 DataGridView1.Item("PD", i).Value = i + 67 DataGridView1.Item("PDP", i).Value = i + 41 DataGridView1.Item("TPD", i).Value = i + 654 + 6 * 13 DataGridView1.Item("TPDP", i).Value = i + 342 Next End Sub Public Sub thread1f1() For i = 501 To 1000 DataGridView1.Item("PD", i).Value = i + 432 DataGridView1.Item("PDP", i).Value = i + 421 DataGridView1.Item("TPD", i).Value = i + 414 DataGridView1.Item("TPDP", i).Value = i + 42 + 4 Next End Sub Public Sub thread1f2() For i = 1001 To 1500 DataGridView1.Item("PD", i).Value = i + 4452 DataGridView1.Item("PDP", i).Value = i + 34 DataGridView1.Item("TPD", i).Value = i + 123 DataGridView1.Item("TPDP", i).Value = i + 44 Next End Sub Public Sub thread1f3() For i = 1501 To 2000 DataGridView1.Item("PD", i).Value = i + 423 DataGridView1.Item("PDP", i).Value = i + 423 DataGridView1.Item("TPD", i).Value = i + 423 DataGridView1.Item("TPDP", i).Value = i + 423 / 2 Next End Sub </code></pre> <p>'//////////////////////////////////////////////////////////////////////////////////////////</p> <pre><code> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click thread0 = New System.Threading.Thread(AddressOf thread1f0) thread0.Start() thread1 = New System.Threading.Thread(AddressOf thread1f1) thread1.Start() thread2 = New System.Threading.Thread(AddressOf thread1f2) thread2.Start() thread3 = New System.Threading.Thread(AddressOf thread1f3) thread3.Start() End Sub Public Sub GetData(ByVal selectCommand As String) Try Dim connectionString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" &amp; strFileName Me.dataAdapter = New OleDbDataAdapter(selectCommand, connectionString) Dim commandBuilder As New OleDbCommandBuilder(Me.dataAdapter) Dim table As New DataTable() table.Locale = System.Globalization.CultureInfo.InvariantCulture Me.dataAdapter.Fill(table) Me.bindingSource1.DataSource = table Me.DataGridView1.AutoResizeColumns( _ DataGridViewAutoSizeColumnsMode.ColumnHeader) Catch ex As OleDbException MessageBox.Show(ex.Message) End Try End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload