Page 1 of 1

Pass Data Table to Report

Posted: Thu Nov 15, 2012 2:10 pm
by Ink
Hi,

I have designed a report which gets its data from a SQL Server Stored Procedure.
At runtime I am calling the Stored Procedure with different parameters based on user input, and populating a DataTable.

Code: Select all

  Using objCmd As New SqlCommand
            objCmd.Connection = objConn
            objCmd.CommandType = CommandType.StoredProcedure
            objCmd.CommandText = "GetStores"
            With objCmd
                .Parameters.AddWithValue("Country", Me.cboCountry.Text)
                .Parameters.AddWithValue("StoreType", Me.cboStoreType.Text)
                .Parameters.AddWithValue("Cycle", CInt(Me.cboCycle.Text))
            End With

            Using da As New SqlDataAdapter(objCmd)
                da.Fill(dt)
            End Using
        End Using

        'Report.RegData(dt)
        Report.Load("D:\Users\Jon\MyReports\AOESQL.mrt")
        Me.StiWebViewer1.Report = Report
        Report.Render()
When da.Fill(dt) executes, the datatable contains the correct data based on the user input.

Me.StiWebViewer1.Report = Report triggers

Code: Select all

 Private Sub StiWebViewer1_GetReportData(sender As Object, e As Stimulsoft.Report.Web.StiReportDataEventArgs) Handles StiWebViewer1.GetReportData

        e.Report.Dictionary.Databases.Clear()
        e.Report.RegData(dt)
        e.Report.Dictionary.Synchronize()
    End Sub
But when my report renders, I get only the page header and no data. I have only previously used Stimulsoft WinForms with XML data and had no problems. I do not understand how to change the data in my report at runtime with the web version. Can you please advise. I have read all posts I can find in the forum but none help.

Thanks,

Jon.

Re: Pass Data Table to Report

Posted: Thu Nov 15, 2012 4:23 pm
by Ink
I have sorted this.

I have changed

e.Report.Dictionary.Databases.Clear()

to

e.Report.Dictionary.Clear()

And named my datatable to match the source in the report, so

e.Report.RegData("GetStores", dt)

Still the best report tool on the market! Keep up the good work Stimulsoft!

Re: Pass Data Table to Report

Posted: Fri Nov 16, 2012 7:14 am
by Alex K.
Hello,

Thank you very much for these words! We are very glad that our product meets your needs.

Re: Pass Data Table to Report

Posted: Sat Nov 17, 2012 2:15 pm
by Ink
Hi,

Now having a new problem with this...
The GetReportData event only seems to fire the first time I do Me.StiWebViewer1.Report = Report
After this the event never fires again, so the data in my report remains cached as the first time I called it.
Can you help?

Jon

Re: Pass Data Table to Report

Posted: Sun Nov 18, 2012 12:08 pm
by Ink
By adding Me.StiWebViewer1.ResetReport() I seem to have solved this.

Re: Pass Data Table to Report

Posted: Mon Nov 19, 2012 6:53 am
by Alex K.
Hello,

Thank you for the information about the solution.