Pass connection string parameter to object data method

2 posts, 0 answers
  1. Phil
    Phil avatar
    2 posts
    Member since:
    Jun 2019

    Posted 18 Jun Link to this post

    I'm currently working with the Standalone Telerik Report Designer and the ASP.NET WebForms 
    <telerik:ReportViewer>

    component in the .aspx file.

    This is an example of a DataObjectMethod that I'm using for the report.

    [DataObjectMethod(DataObjectMethodType.Select)]
    public Dictionary<DateTime, int> GetContactTotals(string connStr)
    {
           var bllCont = new BLLTotals(connStr);
           return bllCont.GetContactTotalsPerMonth();
    }

     

    It will build and display data fine when I pass in a default connection string in the Report Designer, however I want to be able dynamically change the connection string at runtime for the report as it will be using different customer databases. I've tried adding a Report Parameter in the Report Designer, as well as adding a parameter to the Report Viewer component in the .aspx file and setting it from code behind, however I just can't get it to work.

    Is there something I'm missing? Or would this be the correct way to approach this type of problem.

  2. Eric R
    Admin
    Eric R avatar
    47 posts

    Posted 20 Jun Link to this post

    Hi Phil,

    The recommended approach for Assigning the Connection String Dynamically is to use parameters. Note that the DataSource.ConnectionString is not listed in the parameter dropdown and needs to be typed manually.

    For your reference, there are additional methods for doing this and I have listed them below. These are dependent upon what Report Engine the report viewer is using. 


    Embedded Report Engine

    The report viewers using this engine are the Obsolete ASP.NET WebForms and the Desktop viewers. See the Change the Connection String at Runtime KB article for more information.


    Report REST Service

    The report using this engine are the HTML5 based viewers (MVC,Angular,WebForms). See the Change the Connection String in the Resolve Method KB article for more information.


    Lastly, I recommend reviewing the How-To Bind to a BusinessObject KB article.  Please let me know if you have any additional questions. Thank you for choosing Telerik.

    Regards,

    Eric R
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top