Report>Assign Data from Storedprocedure
Report>Assign Data from Storedprocedure
Team,
I am keep searching about assign data at runtime. I have stored procedure (SP) which will return data based on some condition, this SP out put i wish to assign stimul soft report (*.mrt) file at runtime.
I have background application (BG App) which will call each *.mrt file and assign data at runtime to generate out put as PDF. Please share sample code for this requirement.
Thanks,
Kpmsak.
I am keep searching about assign data at runtime. I have stored procedure (SP) which will return data based on some condition, this SP out put i wish to assign stimul soft report (*.mrt) file at runtime.
I have background application (BG App) which will call each *.mrt file and assign data at runtime to generate out put as PDF. Please share sample code for this requirement.
Thanks,
Kpmsak.
Re: Report>Assign Data from Storedprocedure
Hello,
You can fill data from stored procedure to DataSet and pass it to the report with RegData() method.
Also you can add the datasource to report manualy from code:
Thank you.
You can fill data from stored procedure to DataSet and pass it to the report with RegData() method.
Also you can add the datasource to report manualy from code:
Code: Select all
report.Dictionary.Databases.Clear();
report.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", connectionString));
//Add DataSources:
StiSqlSource DS1 = new StiSqlSource("Connection", "Pr01", "Pr01", "execute Pr01", true, false);
//add parameters
StiDataParameter param = new StiDataParameter("@param1", (int)SqlDbType.Int, 1);
DS1.Parameters.Add(param);
report.Dictionary.DataSources.Add(DS1);
// fill data or schema to dataTableDS1 from SqlDataAdapter or SqlDataReader
//...
//Add Columns:
foreach (DataColumn col in dataTableDS1.Columns)
{
DS1.Columns.Add(col.ColumnName, col.DataType);
}
Re: Report>Assign Data from Storedprocedure
Hi Aleksey,
Thanks for your swift reply.
I did the same code but report is not working, meanning out put is not display in the viewer. I have checked the stored procedure (SP) it's working fine. This SP has simple SELECT statment no WHERE class notheing else.
Herewith I am pasting my code, please review and post your comment.
Sqlcmd = new SqlCommand();
Sqlcmd.CommandText = "dbo.USP_GetTemplates";
Sqlcmd.Connection = conn;
Sqlcmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(Sqlcmd);
DataSet ds = new DataSet();
da.Fill(ds);
report.Load(@"D:\Reports\t_TemplateDisplay.mrt");
report.Dictionary.Databases.Clear();
report.Dictionary.DataSources.Clear();
report.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", connstr));
//Add DataSources:
StiSqlSource DS1 = new StiSqlSource("t_Templates", "t_Templates", "t_Templates", "execute dbo.USP_GetTemplates", true, false);
report.Dictionary.DataSources.Add(DS1);
// fill data or schema to dataTableDS1 from SqlDataAdapter or SqlDataReader
//...
//Add Columns:
foreach (DataColumn col in ds.Tables[0].Columns)
{
DS1.Columns.Add(col.ColumnName, col.DataType);
}
report.Compile();
StiWebViewer1.Report = report;
Thanks,
Kpmsak
Thanks for your swift reply.
I did the same code but report is not working, meanning out put is not display in the viewer. I have checked the stored procedure (SP) it's working fine. This SP has simple SELECT statment no WHERE class notheing else.
Herewith I am pasting my code, please review and post your comment.
Sqlcmd = new SqlCommand();
Sqlcmd.CommandText = "dbo.USP_GetTemplates";
Sqlcmd.Connection = conn;
Sqlcmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter(Sqlcmd);
DataSet ds = new DataSet();
da.Fill(ds);
report.Load(@"D:\Reports\t_TemplateDisplay.mrt");
report.Dictionary.Databases.Clear();
report.Dictionary.DataSources.Clear();
report.Dictionary.Databases.Add(new Stimulsoft.Report.Dictionary.StiSqlDatabase("Connection", connstr));
//Add DataSources:
StiSqlSource DS1 = new StiSqlSource("t_Templates", "t_Templates", "t_Templates", "execute dbo.USP_GetTemplates", true, false);
report.Dictionary.DataSources.Add(DS1);
// fill data or schema to dataTableDS1 from SqlDataAdapter or SqlDataReader
//...
//Add Columns:
foreach (DataColumn col in ds.Tables[0].Columns)
{
DS1.Columns.Add(col.ColumnName, col.DataType);
}
report.Compile();
StiWebViewer1.Report = report;
Thanks,
Kpmsak
Re: Report>Assign Data from Storedprocedure
Hello,
Please check that in your report used datasources has the similar names with registered data.
Thank you.
Please check that in your report used datasources has the similar names with registered data.
Thank you.
Re: Report>Assign Data from Storedprocedure
Hi,
Thanks, I have modified the datasource name, and executed report. No out out.
Kpmsak.
Thanks, I have modified the datasource name, and executed report. No out out.
Kpmsak.
Re: Report>Assign Data from Storedprocedure
Hello,
Do I understand you correct that the issue is closed?
Thank you.
Do I understand you correct that the issue is closed?
Thank you.
Re: Report>Assign Data from Storedprocedure
No, still the reported issue is open. Any complete sample code will be appriciated.
Thanks,
Kpmsak
Thanks,
Kpmsak
Re: Report>Assign Data from Storedprocedure
Hello,
Please see the sample code in the second post of this topic.
Thank you.
Please see the sample code in the second post of this topic.
Thank you.