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

13 posts, 0 answers
  1. Alan Rohulich
    Alan Rohulich avatar
    3 posts
    Member since:
    Jan 2010

    Posted 06 Nov 2012 Link to this post

    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

  2. Alan Rohulich
    Alan Rohulich avatar
    3 posts
    Member since:
    Jan 2010

    Posted 07 Nov 2012 Link to this post

    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

  3. DevCraft banner
  4. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 08 Nov 2012 Link to this post

    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!

  5. Ken Lewis
    Ken Lewis avatar
    28 posts
    Member since:
    Sep 2009

    Posted 19 Feb 2013 Link to this post

    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
  6. Syed
    Syed avatar
    8 posts
    Member since:
    Dec 2012

    Posted 05 May 2013 Link to this post

    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
  7. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 06 May 2013 Link to this post

    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.

  8. Ken Lewis
    Ken Lewis avatar
    28 posts
    Member since:
    Sep 2009

    Posted 06 May 2013 Link to this post

    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
  9. Stef
    Admin
    Stef avatar
    3036 posts

    Posted 09 May 2013 Link to this post

    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.

  10. Hotel
    Hotel avatar
    9 posts
    Member since:
    Sep 2014

    Posted 10 Nov 2014 in reply to Alan Rohulich Link to this post

    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.
  11. Alan Rohulich
    Alan Rohulich avatar
    3 posts
    Member since:
    Jan 2010

    Posted 10 Nov 2014 Link to this post

    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
  12. Hrishikesh
    Hrishikesh avatar
    1 posts
    Member since:
    Nov 2014

    Posted 18 Dec 2014 Link to this post

    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
  13. KS
    KS avatar
    165 posts
    Member since:
    Oct 2012

    Posted 22 Dec 2014 in reply to Hrishikesh Link to this post

    Hi,

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

    -KS
  14. Hamada
    Hamada avatar
    3 posts
    Member since:
    Dec 2014

    Posted 22 Apr in reply to Ken Lewis Link to this post

    Thanks Ken it's rely helps a lot !
Back to Top
DevCraft banner