Reputation: 439
I create a C# program and connected to stimulsoft for Make Reports.
I send a Dataset with 2 Datatable to my report with below code:
DataSet ds = new DataSet();
dtP.TableName = "dtP";
dtF.TableName = "dtF";
ds.Tables.Add(dtP);
ds.Tables.Add(dtF);
Report.RegData(ds);
Report.Show();
and "Report" is stireport object.
when my report page shown. my report is empty.
And when sent just 1 datatable as Dataset to my report that's work well.
Solve:
with add below code to my c# program can solve my problem:
objStiReport.Dictionary.Clear();
objStiReport.RegData(ds);
objStiReport.Dictionary.Synchronize();
Upvotes: 5
Views: 12917
Reputation: 11
I use this code:
DataSet PrintData = GetDataFromDb();
StiReport report = new();
StiPdfExportSettings pdfSettings = new();
string exePath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
string fileName = string.Concat(PrintFile, ".mrt");
string printPath = Path.Combine(exePath, "Report", PrintDiscipline, fileName);
ExportFile = string.Concat(ExportFile, "-", DateTime.Now.Year, "-", DateTime.Now.Month, "-", DateTime.Now.Day);
for (int i = 0; i < PrintData.Tables.Count; i++)
{
report.RegData(PrintData.Tables[i].TableName, PrintData);
report.Load(printPath);
report.Render();
}
report.ExportDocument(StiExportFormat.Pdf, ExportFile + ".Pdf", pdfSettings);
Upvotes: 0
Reputation: 29
First open report with stimul report designer
In top of Dictionary tab, click on 'Action', and select 'Import XML Schema' and select your dataset file (with XSD extention) select 'Import XML Schema' and select your dataset file
For add other dataset repeat step 2 but select 'Merg XML Schema'
On your app code, use like this:
StiReport report = new StiReport();
report.Load(Server.MapPath(@"Report.mrt"));
report.Compile();
report.RegData(myDataSet1);
report.RegData(myDataSet2);
StiMobileViewer1.Report = report;
Upvotes: 0
Reputation: 18977
I also had this problem. I tried many ways but no one solve the problem. I changed something in the dictionary in stimulsoft report designer.
1) choose the Data from Dataset, DataTable
data adaptor type
2) Set a name for Name In Source
property (for example DS
)
3) Add some tables to DS
and set the Name In Source
of them to something like this DS.Table1
. Note that it's important to set the Name In Source
property of tables like this.
As I set the Name In Source
property of tables like DS.TableName
, the problem gone away for me.
Upvotes: 4
Reputation: 3929
1. Merge your 2 datables
dtP.Merge(dtF, false, MissingSchemaAction.Add);
1. fill your report with datatable
Report.RegData(dtP);
another way (if datatable are not able to be merge ) is to create one datatable with all column of each datatable
you can create a datarelation to establish a relationship between two datatables but can RegData method understand a relationship (datarelationp) ?
Upvotes: 2