views:

601

answers:

2

I have some reporting services reports in 2005.

The use a shared data source in a rds file

Ideally I want them to use a connection string that is passed in from a configuration file, ideally via ASP.NETs ReportViewer control.

Is this possible?

+1  A: 

Hi, you can do like this

DataSourceCredentials cred = new DataSourceCredentials(); cred.Name = 'credential_name'; cred.UserId = 'user_id'; cred.Password = 'password';

ReportViewer1.ServerReport.SetDataSourceCredential(new DataSourceCredentials[] { cred }); ReportViewer1.ServerReport.Refresh();

Best Regards, Iordan

IordanTanev
Is there a way I can actually set the server name here as well?
AJM
Yes ReportViewer1.ServerReport has proparty called ServerName or ServerUrl it was one or the outher Best Regards,Iordan
IordanTanev
I think the above solution is good for credentails, however what I wanted to do was dynamically set the connection string.
AJM
A: 

You can set the connection string etc dynamically using expression based connection strings

See http://blogs.msdn.com/bwelcker/archive/2005/04/29/413343.aspx

which uses the the same technique as below

http://msdn.microsoft.com/en-us/library/ms156450.aspx (part about Expression-based Connection Strings)

BUT, this is a bit pants as it means you cant preview your reports in the designer.

AJM