Quantcast
Channel: Our ComponentOne » All Posts
Viewing all articles
Browse latest Browse all 14170

Reply To: Set ConnectionString at Runtime isn’t working for me

$
0
0

Good Day,

I followed the instructions which are mentioned in this blog:
http://our.componentone.com/2012/06/01/c1reports-manipulating-connection-string-at-runtime/

But I find that rather cumbersome if you have a lot of subreports.

I decided to try some 'cheating’.
So far it works quite nicely for me.

I’m using the following workflow:
1) Create the Report definitions in the Report Designer; this is my "template" report definition.
2) Replace the connection string in the "template" report definition with your desired connection string.
3) Save this as 'final’ report definition
4) Load and use the 'final’ report definition to create the report

Here is some VB code to illustrate what I’m doing:

Dim reportDefinitionTemplate As String = "C:\SomeFolder\ReportDefinitonTemplate.xml"
Dim reportDefinition As String = "C:\SomeFolder\ReportDefiniton.xml"

Dim xRepoDef As XDocument = XDocument.Load(reportDefinitionTemplate)
For Each xRepoElm As XElement In xRepoDef…<Report>
   xRepoElm.<DataSource>.<ConnectionString>.Value = myConnectionString
Next
xRepoDef.Save(reportDefinition)

C1Report1.Load(reportDefinition, "SomeReport")

Regards

Wolfgang


Viewing all articles
Browse latest Browse all 14170

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>