Pass Data Table to Report

Stimulsoft Reports.WEB discussion
Post Reply
Ink
Posts: 50
Joined: Sat Jul 02, 2011 2:26 am
Location: UK

Pass Data Table to Report

Post 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.
Ink
Posts: 50
Joined: Sat Jul 02, 2011 2:26 am
Location: UK

Re: Pass Data Table to Report

Post 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!
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Pass Data Table to Report

Post by Alex K. »

Hello,

Thank you very much for these words! We are very glad that our product meets your needs.
Ink
Posts: 50
Joined: Sat Jul 02, 2011 2:26 am
Location: UK

Re: Pass Data Table to Report

Post 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
Ink
Posts: 50
Joined: Sat Jul 02, 2011 2:26 am
Location: UK

Re: Pass Data Table to Report

Post by Ink »

By adding Me.StiWebViewer1.ResetReport() I seem to have solved this.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Pass Data Table to Report

Post by Alex K. »

Hello,

Thank you for the information about the solution.
Post Reply