Avatar of fmichail
fmichail
Flag for Canada asked on

how to test RDL report and how to chage datasource at runtime

How to preview Microsoft report (rdlc) in the reportviewer cntrol in the winform if I am using a stored procedure to retreive the data. please notice that the stored procedure includes a parameter.
.NET Programming

Avatar of undefined
Last Comment
fmichail

8/22/2022 - Mon
Scott McDaniel (EE MVE )

This MSDN article gives a pretty thorough walk-through of creating reports in .NET:

https://msdn.microsoft.com/en-us/library/ms252073%28VS.80%29.aspx?f=255&MSPPError=-2147217396

In my case, I created a DataSource for my report, and then retrieved the data needed to populate the report using standard Datatables and such. I then filled my DataSource table(s) with that data, and then used this code to setup and show my report:

 With rvJobCost
                    .LocalReport.DataSources.Clear()
                    Dim rds As New ReportDataSource("ReportData", jobs.Tables("Report"))
                    .LocalReport.DataSources.Add(rds)
                    .LocalReport.SetParameters(params)
                    .RefreshReport()
End With

In the code block above, the rds object is filled using the jobs.Tables("Report"), which was created from the datasource used when creating the report.

I have no idea if this is "best practice" or not, but hopefully some of the more knowledgeable .NET Experts will chime in with better ideas!
fmichail

ASKER
Thanks Scott

The code that you provided is used in runtime, however, how to test the report duing design time (i.e. preview it).

I will read the link that you provided, and let you know, hopefully it has a good way to handle subreports programatically.
ASKER CERTIFIED SOLUTION
Scott McDaniel (EE MVE )

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
fmichail

ASKER
Hi Scott,
Actually it is my mistake, I changed the description of my question (Before I got any answer).Your Answer, and the link is greatly appreciated. And now I know from you that the way to test thereport is always through running it in areport viewer. nks Scott
Your help has saved me hundreds of hours of internet surfing.
fblack61