Quantcast
Channel: Crystal Report Hosting News (SuperBlogAds Network) » crystal report hosting
Viewing all articles
Browse latest Browse all 17

Crystal Report Hosting :: Crystal Report with Asp.Net – Data Set Method

$
0
0
  • First you need to add a dataset to your project.

  • 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.

You can use either windows authentication or SQL server Authentication. In here I’m using SQL server  authentication. If every things fine you can select the database from the database list. (you can also create databases from here)

  • 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 and 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;
}


Viewing all articles
Browse latest Browse all 17

Trending Articles