I have DSN LESS connection in my application and I tried to make that kind of connection when I run my reports but I am obviously doing something wrong.
If I put connection string from my application into SQL connection through designer and it works well.
I played with report.Dictionary.Database.Clear and report.Dictionary.Database.Add(StiODBCDatabase(Database,ConString)) but with no luck.
So, my question is how to dynamically change connection string for ODBC or any other connection.
Regards,
Djole
DSN LESS ODBC Connection
DSN LESS ODBC Connection
Hello,
If you add a connection to the dictionary in the code, and invoke the report.Dictionary.Database.Clear() method, you need to add other elements of the dictionary - tables, columns, relations.
New connection string:
Add DataSources:
Add Columns:
Add Relations:
Thank you.
If you add a connection to the dictionary in the code, and invoke the report.Dictionary.Database.Clear() method, you need to add other elements of the dictionary - tables, columns, relations.
New connection string:
Code: Select all
report.Dictionary.Databases.Clear();
report.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", newConnectionString));
Code: Select all
StiSqlSource DS1 = new StiSqlSource("Connection", "DS1", "DS1", "SELECT * FROM DS1", true, false);
report.Dictionary.DataSources.Add(DS1);
Code: Select all
foreach (DataColumn col in dataTableDS1.Columns)
{
DS1.Columns.Add(col.ColumnName, col.DataType);
}
Code: Select all
StiDataRelation dataRelation = new StiDataRelation("MyRelation", parentDS, childDS, new string[] { "Field" }, new string[] { "Field" });
report.Dictionary.RegRelations();
report.Dictionary.Relations.Add(dataRelation);
DSN LESS ODBC Connection
Yes, I understand that, but I do not want to change dictionary and set all these staff in already defined dictionary. I want just to change connection string. I tried with variable as DSN settings but it does not work.
Can you give me example for changing connection string?
Regards,
Djole
Can you give me example for changing connection string?
Regards,
Djole
DSN LESS ODBC Connection
Never mind. I solved this.
DSN LESS ODBC Connection
Ok!
Have a nice day!
Thank you.
Have a nice day!
Thank you.