Changing connection string

Stimulsoft Reports.WPF discussion
Post Reply
Niqu
Posts: 81
Joined: Wed Aug 08, 2012 9:08 am

Changing connection string

Post by Niqu »

In report I can add connection to sql.
My question is - Is it possible to change connection string for this connection in code?
For example:
In report I add connection with connection string "Data Source=(local);Integrated Security=True;Initial Catalog=Test".
Is it possible to change this connection string on "Data Source=(local);Integrated Security=True;Initial Catalog=Test2" in code?
I have code like this:

Code: Select all

StiReport r = new StiReport();
r.Load("Report.mrt");
var dataSources = r.Dictionary.DataSources
and I was looking for any public property with connection string in object "dataSource" but I couldn't find (I found one private property, but couldn't change it).
Is it possible to achieve what I want?

Thank you in advance for your help.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Changing connection string

Post by HighAley »

Hello.

It's possible to do with next code:

Code: Select all

(report.Dictionary.Databases["Connection"] as StiSqlDatabase).ConnectionString = "YourConnectionString";
Thank you.
Niqu
Posts: 81
Joined: Wed Aug 08, 2012 9:08 am

Re: Changing connection string

Post by Niqu »

That's what I needed. Thank you :)
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Changing connection string

Post by HighAley »

Hello.

We are always glad to help you.
Let us know if you need any additional help.

Thank you.
Post Reply