Fast Report and Stored Procedure

edited 10:34PM in FastReport .NET
Hi everyone, I am trying to set fast-report data-set (Data-tables) using MSSQL Server Stored Procedure, Here is what is did:

1. I create a empty report template with data-source place holder:
2. I get necessary information for report with some code below:
// Get necessary report information 
                        DataTable TicketDetailDataTable = entities.Database.SqlQuery<PrintMixingreport1_Result>(
                            $"EXEC {reportConfig.SqlProcedureName} @CodePlant,@Plant_No,@St_Ticket",
                            new SqlParameter("CodePlant", plantCode), new SqlParameter("Plant_No", plantNo),
                            new SqlParameter("St_Ticket", ticketNo)).ToDataTable();

                        DataTable SheetDataTable = entities.Ticket.Where(x =>
                                x.CodePlant == plantCode && x.Plant_No == plantNo && x.Ticket_No == ticketNo.ToString())
                            .ToDataTable();
I using moreLinq Nuget package, I had noticed that 2 table has rows.

3. I Register dataset for this report:
DataSet ReportDataSet = new DataSet();
            foreach (var key in ReportDataSourceDictionary.Keys)
            {
                ReportDataSourceDictionary[key].TableName = key;
                ReportDataSet.Tables.Add(ReportDataSourceDictionary[key]);
            }

            report.RegisterData(ReportDataSet);

            return report;

4. To make sure I did right thing, I save current Report and open it with fast-report designer:
report.Save(Path.Combine(HostingEnvironment.ApplicationPhysicalPath, "App_Data", "Reports",
                            "ReportTemplates", "templateDebug.frx"));

The Problems is: The table queried by stored procedure is empty (columns) but table instance still exist, What Wrong???

Hope some help, thank every one

Comments

  • Hello!

    Make sure that before saving an empty .frx file for the design, you have explicitly enabled the data source (report.GetDataSource(“TableName”).Enabled = true;) and that DataTable.TableName matches the name in the <Dictionary> (or pass the name as the second argument to report.RegisterData(ds);).

    If the stored procedure returns 0 rows and ToDataTable() from MoreLINQ does not create a DataColumn or uses a Nullable<T> with a non-standard type, populate the schema using SqlDataAdapter.FillSchema(dt, SchemaType.Source) or pass a List<PrintMixingreport1_Result> directly to report.RegisterData(list, “Mixing”, 2) — FastReport does an excellent job of building columns based on the properties of EF POCO classes without a DataTable

This discussion has been closed.