- Then Black Screen will be shown. Now you have to add database tables to your datasets. thus if you did not have any database connection yet create one using server explorer.
- Then Drag and drop the tables to the dataset designer.
- Now you can design your report but we will do little a little advance thing. Assume you want to get Table1’s Names by giving the Year. Now you want to pass parameter to the query. So you want to add a new method to a table1’s Data Adapter. For that,
do as above and generate your query using the query designer as follows.
and click finished. Now can see new method is inserted to your table1’s Data Adapter.
Now you want to design the Crystal report. For that as previous article you can add a new crystal report with blank report option. Now you want to configure the report to get the data from the data set. Thus, go to the database explorer and and the data set to the report as follows. |
Finally click ok and design your report by drag and dropping tables fields. |
Now you want to code the report.aspx page to load the report.
protected void Page_Load(object sender, EventArgs e)
{
int Year = 12; // you can also get this from query string;
ReportDocument CollReport = new ReportDocument();
string reportPath = Server.MapPath("CrystalReport1.rpt");
CollReport.Load(reportPath);
DataSet1TableAdapters.Table1TableAdapter ta = new WebApplication2.DataSet1TableAdapters.Table1TableAdapter();
DataSet1.Table1DataTable dt = new DataSet1.Table1DataTable();
ta.FillBy(dt, Year);
CollReport.SetDataSource((DataTable)dt);
CrystalReportViewer1.ReportSource = CollReport;
}
Comments
http://www.c-sharpcorner.com/UploadFile/rsubhajit/CrystalReportwithDataSet03012006060655AM/CrystalReportwithDataSet.aspx
http://www.mindstick.com/Articles/b1fa8372-12c0-4b0e-a870-138fe135a095/?Crystal%20Report%20with%20DataSet
It is also explained very well about Crystal Report with DataSet. Thanks Everyone for nice post.