Page 1 of 1

Changing connection string

Posted: Mon Mar 17, 2014 9:50 am
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.

Re: Changing connection string

Posted: Mon Mar 17, 2014 12:52 pm
by HighAley
Hello.

It's possible to do with next code:

Code: Select all

(report.Dictionary.Databases["Connection"] as StiSqlDatabase).ConnectionString = "YourConnectionString";
Thank you.

Re: Changing connection string

Posted: Tue Mar 18, 2014 7:24 am
by Niqu
That's what I needed. Thank you :)

Re: Changing connection string

Posted: Tue Mar 18, 2014 7:27 am
by HighAley
Hello.

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

Thank you.