Retrieve Columns Automatically

Stimulsoft Reports.WEB discussion
Post Reply
tp182
Posts: 6
Joined: Thu Mar 21, 2013 11:39 am

Retrieve Columns Automatically

Post by tp182 »

I have managed to add data source through code, is there any way i can auto populate the columns from a view or stored procedure in the designer ?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Retrieve Columns Automatically

Post by Alex K. »

Hello,

You can use the following code.
New connection string:
report.Dictionary.Databases.Clear();
report.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", newConnectionString));

Add DataSources:
StiSqlSource DS1 = new StiSqlSource("Connection", "DS1", "DS1", "SELECT * FROM DS1", true, false);
report.Dictionary.DataSources.Add(DS1);

Add Columns:
foreach (DataColumn col in dataTableDS1.Columns)
{
DS1.Columns.Add(col.ColumnName, col.DataType);
}

Thank you.
tp182
Posts: 6
Joined: Thu Mar 21, 2013 11:39 am

Re: Retrieve Columns Automatically

Post by tp182 »

Thanks Aleksey I've got it working now.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Retrieve Columns Automatically

Post by Alex K. »

Hello,

Ok.
Let us know if you need any additional help.

Thank you.
Post Reply