VB.NET / MS Access Threading Issue...
-
I am running a procedure in a thread which is created on the click of a button. However, the process does not complete correctly. Please refer to the code below: Private Sub cmdProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdProcess.Click Try Dim tquery As Thread tquery = New Thread(AddressOf Me.GetData) tquery.Start() Catch ex As Exception MessageBox.Show(ex.Message, "Error In cmdProcess_Click", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub Private Sub GetData() Try Dim field1, field2, op1, period1, value1 As String Dim m1, y1, tablename As String period1 = Trim(cmbPeriod.Text) m1 = Mid(Trim(period1), 5, 2) y1 = Mid(Trim(period1), 3, 2) tablename = "SSA" & m1 & y1 field1 = Trim(cmbField1.Text) value1 = Trim(cmbValue.Text) op1 = Trim(cmbOP1.Text) field2 = Trim(cmbField2.Text) str = "select " & Trim(op1) & "(" & Trim(field2) & ") from " & Trim(tablename) & " group by " & Trim(field1) & " order by " & Trim(field1) ipcon.Open() DA = New OleDbDataAdapter(str, ipcon) DS = New DataSet DA.Fill(DS, "qrec") ipcon.Close() DataGrid1.SetDataBinding(DS, "qrec") Catch ex As Exception MessageBox.Show(ex.Message, "Error In GetData", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub -- This code exits with the following error message 'Controls created on one thread cannot be parented to a control on a different thread' Please guide me how to resolve this issue. With Best Regards, Mayur