I test an application with crystal report. I create 1 dataset with 4 tables (master, items, solution, evaluation) and this is my code
//Master
dsMaster.Tables["master"].ImportRow(dtMaster.Rows[0]);
//Items
DataTable dtItems = getItems(_mdReqMaster.id);
if(dtItems.Rows.Count > 0){
foreach(DataRow dr in dtItems.Rows){
dsMaster.Tables["items"].ImportRow(dr);
}
}
//TeamTech
DataTable dtTechnicians = getTechnicians(_mdReqMaster.id);
if (dtTechnicians.Rows.Count > 0)
{
foreach (DataRow dr in dtTechnicians.Rows)
{
dsMaster.Tables["technicians"].ImportRow(dr);
}
}
//Solution
DataTable dtSolution = getSolution(_mdReqMaster.id);
if (dtSolution.Rows.Count > 0)
{
foreach (DataRow dr in dtSolution.Rows)
{
dsMaster.Tables["solutions"].ImportRow(dr);
}
}
//Evaluate
DataTable dtEvaluate = getEvaluate(_mdReqMaster.id);
if (dtEvaluate.Rows.Count > 0)
{
foreach (DataRow dr in dtEvaluate.Rows)
{
dsMaster.Tables["evaluation"].ImportRow(dr);
}
}
Data added see my picture:
report.Load(Path.Combine(
HostingEnvironment.MapPath("~/Reports/"), "report.rpt"));
//report.Database.Tables[0].SetDataSource(dsMaster.Tables[0]);
//report.Database.Tables[1].SetDataSource(dsMaster.Tables[1]);
report.SetDataSource(dsMaster);
report.Refresh();
Stream stream = report.ExportToStream(ExportFormatType.PortableDocFormat);
MemoryStream streamReader = new MemoryStream();
stream.CopyTo(streamReader);
return streamReader.ToArray();
Output:
I get only data from table master. And when I use Database. Tables[0].SetDataSource(dsMaster.Tables[0]) I get login error, looks like I need to set login to report and I think I don't need to set that because I use dataset. Can someone help me, please? Thank you so much.
My problem is me, i'm use another table in sub report then i need to add that data to sub report