출처: http://forums.asp.net/t/1442445.aspx/1
크리스탈 리포트를 사용할때 여러개의 테이블을 사용할 경우가 많다.
구글 검색해도 잘 못찾다가 자세히 읽어보니.. 답이 나온다..
영어 대충 읽으면 안될듯..ㅠㅠ
이것이 핵심..ㅠㅠ
report.Database.Tables[0].SetDataSource(ds.Tables[0]); report.Database.Tables[1].SetDataSource(ds.Tables[1]); |
using CrystalDecisions.CrystalReports.Engine;
ReportDocument report = new ReportDocument();
DataSet ds = new DataSet();
ds = FillMyDataset(); //// fill your dataset.
report.Load(Server.MapPath("your_reportFilename_goes_here.rpt"));
report.SetDataSource(ds.Tables[0]); /// commonly used for single tabled reports...
/// for multiple tables
report.Database.Tables[0].SetDataSource(ds.Tables[0]);
report.Database.Tables[1].SetDataSource(ds.Tables[1]);
report.Database.Tables[2].SetDataSource(ds.Tables[2]);
...
report.Database.Tables[n].SetDataSource(ds.Tables[n]);
/// In case if you're using sub - reports, try this
report.Subreports[0].SetDataSource(ds.Tables[1]);
report.Subreports[1].SetDataSource(ds.Tables[2]);
Dont forget to mark as answer if this helps you.