K
KeesBlunder
Guest
Hello,
I fill a datagridview from a database , no problem.
But when i fill it with a Backgroundworker there is an error, i never worked with Backgroundworker .
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
BackgroundWorker3.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker3_DoWork(sender As Object, e As DoWorkEventArgs) Handles BackgroundWorker3.DoWork
cmd = New SqlCeCommand("SELECT * FROM Telboek ", con)
If con.State = ConnectionState.Closed Then con.Open()
myDA = New SqlCeDataAdapter(cmd)
myDataSet = New DataSet()
myDA.Fill(myDataSet, "MyTable")
DataGridView1.DataSource = myDataSet.Tables("MyTable").DefaultView
If con.State = ConnectionState.Open Then con.Close()
End Sub
The error is
System.InvalidOperationException
HResult=0x80131509
Message = It is not allowed to execute an operation through different threads: from another thread, the DataGridView1 control was accessed from the thread on which the element was created.
What does this means ?
Continue reading...
I fill a datagridview from a database , no problem.
But when i fill it with a Backgroundworker there is an error, i never worked with Backgroundworker .
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
BackgroundWorker3.RunWorkerAsync()
End Sub
Private Sub BackgroundWorker3_DoWork(sender As Object, e As DoWorkEventArgs) Handles BackgroundWorker3.DoWork
cmd = New SqlCeCommand("SELECT * FROM Telboek ", con)
If con.State = ConnectionState.Closed Then con.Open()
myDA = New SqlCeDataAdapter(cmd)
myDataSet = New DataSet()
myDA.Fill(myDataSet, "MyTable")
DataGridView1.DataSource = myDataSet.Tables("MyTable").DefaultView
If con.State = ConnectionState.Open Then con.Close()
End Sub
The error is
System.InvalidOperationException
HResult=0x80131509
Message = It is not allowed to execute an operation through different threads: from another thread, the DataGridView1 control was accessed from the thread on which the element was created.
What does this means ?
Continue reading...