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

Pass connection string parameter to object data method

1 Answer 401 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Phil
Top achievements
Rank 1
Phil asked on 18 Jun 2019, 08:45 AM
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.

1 Answer, 1 is accepted

Sort by
0
Accepted
Eric R | Senior Technical Support Engineer
Telerik team
answered on 20 Jun 2019, 06:39 PM
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
Tags
General Discussions
Asked by
Phil
Top achievements
Rank 1
Answers by
Eric R | Senior Technical Support Engineer
Telerik team
Share this question
or