Friday, February 24, 2012

Dynamic Connection String

Hi, Can I pass the connection string dynamically. That means the user will specify the database, he/she wants to connects to and user name and password for the same and display and list of Models/Reports stored in that database.Yes, you can. After all the ConnectionString is just a string. So before you make an SqlConnection, you build up the ConnectionString.


string userName = "Joe";
string password = "****";
string server = "MyDatabaseServer";
string connectionString="user="+userName+";password="+password etc etc

Of course this is a ugly fasttype example. You can beautify this using StringBuilders etc.|||Thanks. But, I wanted to know how this can be passed dynamically when the user runs the report from the report server. Which means, the report is already designed and published on the report server. Firstly, can a report/report model be designed on dynamic connection string.|||I think the question was about dynamic connection strings in Reporting Services. This is a feature of SQL Server 2005 Reporting Services. There are a couple of workarounds for SQL 2000 RS (stored procs, cross database queries, etc.).

No comments:

Post a Comment