Hi all,

I have a program which connects to sql and uses crystal reports. I have many records and crystal reports takes a while to load up. Would multi threading help improve performance? Here is my code:

Private Sub EmpLog_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim report As New Crystal_Report1
        report.SetParameterValue("EmployeeName", DSReport.Tables(0).Rows(0).Item("name"))
        report.SetDatabaseLogon("login", "password")

        CrystalReportViewer1.ReportSource = report

    End Sub

I want to somehow speed this up. Thanks in advance.

Whats the differnece between the background worker and using threads? I'm kinda confused still.

lolwtf,
You must read MSDN online page (link at - #2).
BackgroundWorker is a class that runs in a separate thread. When the BackgroundWorker class's thread calls a method, or does anything else with the Form, it is doing it in the context of its' own separate thread.

lolwtf,
You must read MSDN online page (link at - #2).
BackgroundWorker is a class that runs in a separate thread. When the BackgroundWorker class's thread calls a method, or does anything else with the Form, it is doing it in the context of its' own separate thread.

Okay i took a look at the article and incorporated some code into my project. The problem is i have another form that's coming up with a report viewer loading the crystal reports. Here is the code i added to the first form that loads the second with a button:

DBALog.SelectCommand.CommandText = "SELECT FName + ' ' + LName AS [name] FROM tblEmployee WHERE EmployeeID = " + DGVTime.SelectedRows(0).Cells("EmployeeID").Value.ToString + ";"
        Dim dsreport As New DataSet
        DBALog.Fill(dsreport)

        prgThread.Value = 0
        BackgroundWorker1.WorkerReportsProgress = True
        BackgroundWorker1.WorkerSupportsCancellation = True
        BackgroundWorker1.RunWorkerAsync()
        Dim newform As New EmpLog(dsreport)
        newform.MdiParent = Me.MdiParent
        newform.Size = Me.Size
        newform.Show()

Now heres the code for the other form:

Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        Dim report As New Crystal_Report1
        report.SetParameterValue("EmployeeName", DSReport.Tables(0).Rows(0).Item("name"))
        report.SetDatabaseLogon("login", "password")

        CrystalReportViewer1.ReportSource = report


        

    End Sub

Normally i would put that code in the form load event. Now nothing displays in my report viewer. This is starting to get too advanced for my knowledge.

This question has already been answered. Start a new discussion instead.