Pull InstanceReportSource name from Database

2 posts, 0 answers
  1. Mike Maynard
    Mike Maynard avatar
    3 posts
    Member since:
    May 2003

    Posted 01 Oct 2014 Link to this post

    Hi everyone,
    I am deploying a custom winform application that will use a database table to lookup reports that a user is allowed access to.
    The table is just 3 fields
    rptID, rptName, and rptDescription

    On load of the Report  Form I query the database using the users ID and pull in the 3 fields above to create a group of radio buttons on the form.
    What I need to be able to do is then load another form with a reportviewer on it when the user selects a radio button.

    Is there anyway to take the string value of rptName and dynamically load it into the ReportViewer on the called form?

    I am using instancereportsource with a compiled DLL of reports.

    I can hard code the reports and use a Select Case on reportname but I would rather have it be dynamic so that I can add reports later on after the application is deployed by just replacing the reports DLL file.

    The code I currently use for the hard coded select case is
    Select Case ReportName
                Case "IncidentListingReporting" 
                    Dim FullnameRpt2 As New Telerik.Reporting.InstanceReportSource 
                    FullnameRpt2.ReportDocument = New Reporting.IncidentListingReport
                    FullnameRpt2.Parameters.Add(New Telerik.Reporting.Parameter("SDate", Param2))
                    FullnameRpt2.Parameters.Add(New Telerik.Reporting.Parameter("EDate", Param3))
                    FullnameRpt2.Parameters.Add(New Telerik.Reporting.Parameter("PNUM", Param4))
                    ReportViewer2.ReportSource = FullnameRpt2
    End Select

    What I would like is to be able to do something like
                    FullnameRpt2.ReportDocument = Param1

    Thanks for any help!


  2. Nasko
    Admin
    Nasko avatar
    1049 posts

    Posted 06 Oct 2014 Link to this post

    Hello Mike,

    You can use the Activator.CreateInstance Method after retrieving the correct type name from the database.

    Another approach is to replace the InstanceReportSource with another report source more suitable in your scenario. Please check the available report sources in the Report Sources help article.

    Regards,
    Nasko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top