I have a crystal report named CR1. Now i want to populate the data from multiple tables into my crystal report CR1. I am using VS2008 and coding language is C# in ASP.net Any help will be appreciated.
Create a stored procedure and then use it as a data source of your report. It will help.
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter("select Table1.Col1,Table2.Col2,Table3.Col3 From Table1,Table2,Table3 where Table1.id=Table2.id and Table2.id=Table3.id", con);
da.Fill(ds);
CrystalDecisions.CrystalReports.Engine.ReportDocument myReportDocument;
myReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
myReportdocument.Load(@"MyPathToReportFile.rpt");
myReportdocument.Database.Tables[0].SetDataSource(ds);
CrystalReportViewer1.ReportSource = myReportDocument;
CrystalReportViewer1.DataBind();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.