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

Custom connection string for Parameter values

3 Answers 87 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Andrew Nixon
Top achievements
Rank 1
Andrew Nixon asked on 03 Jun 2010, 04:36 PM
Hi,
I have a solution where some data is passed in a parameter to the report and the report decides which database to retrieve it's data from based on those values. This works fine for the report's datasource as I use the NeedDataSource event to connect the report to the appropriate db at runtime. 
How do I do this for parameters which are bound to SqlDataSource's?
The queries for the parameters seem to be executed too early and I can't find a 'needdatasource' event for the sqldatasource to give the appropriate connection strings.

Thanks

Andrew

3 Answers, 1 is accepted

Sort by
0
Massimiliano Bassili
Top achievements
Rank 1
answered on 03 Jun 2010, 05:04 PM
This is a tricky question and a tricky answer would be "the same way as you do with asp:SqlDataSource control". Seriously now, you should use a report parameter to pass the value you need directly to the database parameter. Or if you're a "code guy", you could do this with code like shown in the docs: Using Parameters with the SqlDataSource component.

Cheers!
0
Andrew Nixon
Top achievements
Rank 1
answered on 03 Jun 2010, 05:26 PM
That works fine if I just want to change the data I get back from the database, I need to change the actual database to which I connect.

Thanks

Andrew
0
Massimiliano Bassili
Top achievements
Rank 1
answered on 04 Jun 2010, 08:33 AM
This sounds quite counter intuitive as the SqlDataSource components are there to help you bind the reports quick and easy during design time and it makes little sense to me to change their settings in runtime, although you can access them through this.SqlDataSource .... binding through NeedDataSource sounds like the way to go in such scenario.
Tags
General Discussions
Asked by
Andrew Nixon
Top achievements
Rank 1
Answers by
Massimiliano Bassili
Top achievements
Rank 1
Andrew Nixon
Top achievements
Rank 1
Share this question
or