Hi,
Can you help me adding new datasource (more than one with different connection) to existing report using c#?
Thanks,
Vatsal Desai
How to add new datasource in existing report from code?
Re: How to add new datasource in existing report from code?
Hello,
You can use the following code.
New connection string:
Add DataSources:
Add Columns:
Add Relations:
Thank you.
You can use the following code.
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);
Re: How to add new datasource in existing report from code?
Hi,
Thanks for your help but I am not able to get object "Stimulsoft.Report.Dictionary.StiSqlDatabase" in my application. I have added below references to my project:
Stimulsoft.Base
Stimulsoft.Report
Stimulsoft.Report.Web
Stimulsoft.Report.WebDesigner
Is there any reference missing from my project? Do I need to add any other reference to my project?
Thanks again for your kind help
Vatsal
Thanks for your help but I am not able to get object "Stimulsoft.Report.Dictionary.StiSqlDatabase" in my application. I have added below references to my project:
Stimulsoft.Base
Stimulsoft.Report
Stimulsoft.Report.Web
Stimulsoft.Report.WebDesigner
Is there any reference missing from my project? Do I need to add any other reference to my project?
Thanks again for your kind help
Vatsal
Re: How to add new datasource in existing report from code?
Hello.
Thank you.
The Stimulsoft.Report.Dictionary.StiSqlDatabase class is in the Stimulsoft.Report assembly.vatsal24 wrote:Thanks for your help but I am not able to get object "Stimulsoft.Report.Dictionary.StiSqlDatabase" in my application. I have added below references to my project:
Stimulsoft.Base
Stimulsoft.Report
Stimulsoft.Report.Web
Stimulsoft.Report.WebDesigner
Is there any reference missing from my project? Do I need to add any other reference to my project?
Thank you.