This is a migrated thread and some comments may be shown as answers.

Passing parameters to report from .Net web form (VB.Net Solution)

12 Answers 493 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Alan Rohulich
Top achievements
Rank 1
Alan Rohulich asked on 06 Nov 2012, 03:51 PM
I am also trying to pass parameters to a report from a .NET aspx web form. I tried converting your C# solution to VB.Net and was unsuccessful. I am using the following code:

Dim Report1 as New Telerik.Reporting.Report
Dim instanceReportSource =  New Telerik.Reporting.InstanceReportSource()
instanceReportSource.ReportDocument = Report1
ReportViewer1. ReportSource = Report1
Report1.ReportParameters("@Loc").Value = "Corporate Plaza"   <<===== ERROR ON THIS LINE
ReportViewer1.RefreshReport()


I get an error stating that an Object reference not set to an instance of an object.

Use the "New" keyword to create an object instance.

I have  tried several things and so far have not been able to get past this point.

Your help would be greatly appreciated as once I have the parameter passing working my management will be ready to pull the trigger on purchasing your "Reporting" tools and possibly some other packages.

Thanks in advance,
Alan

12 Answers, 1 is accepted

Sort by
0
Alan Rohulich
Top achievements
Rank 1
answered on 07 Nov 2012, 04:47 PM
I just figured this out by scanning many of the forum entries. The answer was discovered in the forum titled "How to migrate your project to utilize the new ReportSource object". It was by accident that I even looked inside this forum for information regarding parameter passing. Since the object options provided in VB.net do not even list "Parameters" as an option under the instanceReortSource and the "Add" option also does not appear under the "Parameters" option. I would have never solved this without the information in this post. Once I got it working  the rest is simple for using the parameters on the Report. I would suggest you update your documentation to demonstrate how this is done and hopefully save other clients many hours of trial and error frustrations for getting this working. 

Here is the code to accomplish the parameter passing in VB.Net:

Dim Report1 as New Telerik.Reporting.Report
Dim instanceReportSource = New Telerik.Reporting.InstanceReportSource()
ReportViewer1.ReportSource = instanceReportSource
instanceReportSource.ReportDocument = New Report1
instanceReportSource.Parameters.Add(New Telerik.Reporting.Parameter("Date",  "4/9/2012"))
ReportViewer1.RefreshReport()

In the code Report1.vb [Design] use @Date as the parameter in your SqlDataSource and Configure the Data Source Parameters  to use  @Date =Parameters.Date.Value.

That's all there is to it.


Regards,
Alan

0
Steve
Telerik team
answered on 08 Nov 2012, 09:06 AM
Hello Alan,

We're sorry to hear you had such a hard time working with our report parameters. We have the information you have found in the KB article available in the documentation in the Report Sources help section (as the parameters are now part of the ReportSources and when provided, the values of the ReportSource parameters are applied to the Report parameters at run-time.)

All the best,
Steve
the Telerik team

HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

0
Ken Lewis
Top achievements
Rank 1
answered on 19 Feb 2013, 07:17 PM
Hi Alan,

Thanks for your post. That was more helpful than the documentation since it included the RefreshReport method.

I'm posting the code that worked for me as yet another example of setting report parameters in Q3 2012. The code below (in C#) is in the OnLoad event of the ASPX page. ReportVIewer1's report source (type in this case) is defined on the page itself.

ReportViewer1.ReportSource.Parameters.Add(new Telerik.Reporting.Parameter("MyYear", "2012"));
ReportViewer1.RefreshReport();

I hope others find it useful.

Ken
0
Hamid
Top achievements
Rank 1
answered on 05 May 2013, 09:53 PM
Thank you very much Ken

I searched for this line of code for few days.
Nothing of this sort in Telerik documentation (read documentation, saw videos and studied demos), I am sorry to say
so grateful

Hamid
0
Stef
Telerik team
answered on 06 May 2013, 03:58 PM
Hello Hamid,

Please check How to: Set ReportSource for Report Viewers help article and how parameters are passed to the report document through the report source object.

I hope this helps.

Greetings,
Stef
the Telerik team

Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.

0
Ken Lewis
Top achievements
Rank 1
answered on 06 May 2013, 08:54 PM
Hi Stef,

Yes, the link is helpful, but it's not the full story. Just getting the syntax right for adding a parameter isn't enough. We also need to know that it's necessary to call RefreshReport. Otherwise, we can set parameters until we're blue in the face and nothing will happen.

Please add a note about calling RefreshReport to the documentation.

Thanks,

Ken
0
Stef
Telerik team
answered on 09 May 2013, 02:18 PM
Hi Ken,

Calling RefreshReport depends on the selected technology and programming language. These specific cases when you need to use the method are listed in the different articles in the Using Telerik Reporting in Applications section, e.g. How to: Add report viewer to a web page.

Let us know if you have any further concerns.

Regards,
Stef
the Telerik team

Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.

0
Hotel
Top achievements
Rank 1
answered on 10 Nov 2014, 06:00 PM
Greetings,
I did what you suggested, but I could not do the last part of the report. I could drive a little more? attached image where I think the code is inserted.

or not know I have error code.
0
Alan Rohulich
Top achievements
Rank 1
answered on 10 Nov 2014, 06:26 PM
Hotel,

You may want to eliminate the "@" character in the parameter name. My parameters were all normal alpha based names and they worked  ok. I never tried using any special characters in the name. Hope this helps.

Regards,
Alan
0
Hrishikesh
Top achievements
Rank 1
answered on 18 Dec 2014, 02:09 PM
I have one problem in vb.net
i was create invoice report page (Report.vb) and i need to call this page 
on invoice.aspx page. But i can not call this page.plz help me.
I create this form using telerik control.

Thanking you,

Hrishikesh
0
KS
Top achievements
Rank 1
answered on 22 Dec 2014, 08:52 AM
Hi,

You need a viewer control like Html5 Report Viewer. It has a VS template to help you start - Quickstart.

-KS
0
Hamada
Top achievements
Rank 1
answered on 22 Apr 2016, 02:35 PM
Thanks Ken it's rely helps a lot !
Tags
General Discussions
Asked by
Alan Rohulich
Top achievements
Rank 1
Answers by
Alan Rohulich
Top achievements
Rank 1
Steve
Telerik team
Ken Lewis
Top achievements
Rank 1
Hamid
Top achievements
Rank 1
Stef
Telerik team
Hotel
Top achievements
Rank 1
Hrishikesh
Top achievements
Rank 1
KS
Top achievements
Rank 1
Hamada
Top achievements
Rank 1
Share this question
or