centech-group
asked on
Multiple Threads using Active Reports
I am using dynamic SQL (put into strSelect in my program) to fill an ActiveReports report. This is the code I use to set the datasource for the report (ActiveReports requires using OleDb in this case) :
'set up connection string and dataset
Dim connString As String = "Provider=SQLOLEDB.1;" & myConnectionString
Dim conn As New OleDb.OleDbConnection(conn String)
conn.Open()
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter(str Select, conn)
da.Fill(ds, "Detail")
rpt.DataSource = ds
rpt.DataMember = "Detail"
The problem is that the fill can take a long time if there’s a lot of data and the user can’t do anything else. I would like to run fill in a separate thread, but I would have to know when it is finished, so I can run the report. The events I see for OleDbDataAdapter don’t seem to include one for fill completed. Do you know of any other way I can prevent the fill process from locking up the machine?
'set up connection string and dataset
Dim connString As String = "Provider=SQLOLEDB.1;" & myConnectionString
Dim conn As New OleDb.OleDbConnection(conn
conn.Open()
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter(str
da.Fill(ds, "Detail")
rpt.DataSource = ds
rpt.DataMember = "Detail"
The problem is that the fill can take a long time if there’s a lot of data and the user can’t do anything else. I would like to run fill in a separate thread, but I would have to know when it is finished, so I can run the report. The events I see for OleDbDataAdapter don’t seem to include one for fill completed. Do you know of any other way I can prevent the fill process from locking up the machine?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Private Sub BackgroundWorker1_DoWork(B
'set up connection string and dataset
Dim connString As String = "Provider=SQLOLEDB.1;" & myConnectionString
Dim conn As New OleDb.OleDbConnection(conn
conn.Open()
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter(str
da.Fill(ds, "Detail")
e.Result = ds
End Sub
Private Sub BackgroundWorker1_RunWorke
rpt.DataSource = CType(e.Result, DataSet)
rpt.DataMember = "Detail"
End Sub