Groups | Blog | Home
all groups > sql server reporting services > november 2005 >

sql server reporting services : Set Connection String through code - can this be done?


Meade Robboy
11/28/2005 4:17:35 PM
First, let me say that I am trying to use Server Reports with the Winform
Report Viewer.

This is a technique I used heavily in Crystal.
It allowed me to build the reports against the development servers (Web &
SQL), and copy the report files to one or more production servers, where the
connection settings (SQL Server (Data Source), Database (Initial Catalog),
Login (User ID), and Password could be set through code for the report and
all subreports.

I understand the steps are a little different with reporting services, but
this seems pretty basic.
Is there really no way to do this? Maybe something not so obvious?

Thanks for any help in advance,
-Meade

Teo Lachev [MVP]
11/28/2005 10:16:28 PM
RS 2005 support expression-based connection strings with private data
sources. Look at the ExpressionBasedConnection sample report here
(http://prologika.com/CS/blogs/blog/archive/2005/10/05/687.aspx).

--
HTH,
----------------------------------------------
Teo Lachev, MVP, MCSD, MCT
"Microsoft Reporting Services in Action"
"Applied Microsoft Analysis Services 2005"
Home page and blog: http://www.prologika.com/
----------------------------------------------
[quoted text, click to view]

NO[at]SPAM je
11/29/2005 12:00:00 AM
Meade, RS uses a datasource entity on the server, this is were the
connectionstring lives, you can use the same name for the datasource but
they datasources can be different from server to server.

HTH,
Ed Richard

[quoted text, click to view]

scott.hunley NO[at]SPAM cox.net
12/7/2005 8:46:13 AM
Can you explain a little more how to set up the Expression-Based
Connection Strings. I am looking at your code download and I am a
little lost. I am new to Reporting Services and I am trying to set it
up so that my reports, which are cmmon among several customers, can be
reused by simply changing the connection string (initial catalog, maybe
the data source/server).

Thanks in advance for any help that you can give.

Scott
Teo Lachev [MVP]
12/7/2005 10:20:32 PM
1. Set up a private data source.
2. In the Connection string property enter a VB.NET expression that returns
your connection string.

In my case, I am calling a property in an external .NET assembly which gets
the connection string from the Report Server web.config at runtime. At
design time, the GetConnectionString property returns a constant so the
report won't blow up in the Report Designer.

--
HTH,
----------------------------------------------
Teo Lachev, MVP, MCSD, MCT
"Microsoft Reporting Services in Action"
"Applied Microsoft Analysis Services 2005"
Home page and blog: http://www.prologika.com/

-------------------------------------------------
[quoted text, click to view]

scott.hunley NO[at]SPAM cox.net
12/8/2005 11:44:10 AM
Does this have to use VB.NET? The component I am using is written in
C#. I am trying to the code that I downloaded from your site:
AdventureWorks.Utils.ConnectionString. I am attempting to check the
querystring for a parameter (DB=name) to decide which connection string
to pull from the web.config file on the Report Server. Currently I
just have it where it should default to returning me the connection
string that I have declared as a constant, just to prove that it works
on the server. However, I am getting the following error when I deploy
the report and try to run it:

An error has occurred during report processing.
Error during processing of the ConnectString expression of datasource
'AdventureWorksPrivate'.

I deployed the private assembly to the bin folder on the report server:

C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting
Services\ReportServer\bin

Am I missing something? Should I sign the assembly and deploy it to
the GAC? I can't understand why it finds it on the IDE, but not on the
server.

Any help would be greatly appreciated.

Thanks,

Scott
Teo Lachev [MVP]
12/9/2005 8:24:46 AM
[quoted text, click to view]
No, you can use whatever language you want.

[quoted text, click to view]

No, you don't have to. What is probably missing is granting your assembly
CAS rights in rssrvpolicy.config,e .g.

<CodeGroup class="UnionCodeGroup" version="1"
Name="SecurityExtensionCodeGroup" Description="Code group for the
AdventureWorks Utils library" PermissionSetName="FullTrust">
<IMembershipCondition class="UrlMembershipCondition" version="1"
Url="C:\Program Files\Microsoft SQL Server\MSSQL.3\Reporting
Services\ReportServer\bin\AdventureWorks.dll"
/>
</CodeGroup>
--
HTH,
----------------------------------------------
Teo Lachev, MVP, MCSD, MCT
"Microsoft Reporting Services in Action"
"Applied Microsoft Analysis Services 2005"
Home page and blog: http://www.prologika.com/

-------------------------------------------------
[quoted text, click to view]

scott.hunley NO[at]SPAM cox.net
12/14/2005 9:32:59 AM
Thanks alot for your time, you've been a tremendous help.

Scott
AddThis Social Bookmark Button