I am going to explain how to create a report by using Crystal Report in DotNet here.
To create a report using crystal report, just follow the steps mentioned below which is very useful to using crystal repot.
In Visual Studio 2005, create new project with a name as your wish. Add a new item to the project by right clicking on the project name in solution explorer. Select the crystal report template with a name as your wish.
Now you are in Crystal Report Gallery dialog. Now you should choose the “Using the Report Wizard” and “Standard” options and click OK.
The Standard Report Creation Wizard dialog will appear. Now you should choose the data source to connect SQL Server 2005. For that just expand the Create New Connection data source and expand the OLEDB(ADO) item. Then select an OLEDB provider “SQL Native Client” for SQL Server 2005 databases.
Now we need to provide the connection information for the database. Type the server name and check the Integrity Security checkbox. Then click the dropdown list next to the database item and select the database. Click the next to continue, in next dialog finish to configuring the data source.
Now you need to choose the tables to use for the report. Expand your database and select the tables by using > button.
Click the next to continue. Here you need to confirm the relationships between the various tables you have selected. Then click the next to continue.
Now you should choose the fields to use for the report by using > button. Then click next, in the next dialog you should choose the field to group the report.
Clicks next to continue there will three dialogs seemed. Just give next and next, in final dialog you can select report style finally click finish then your report will be ready.
After creating the report, you can preview that by clicking the Main Report Preview button which is in the bottom of report.
Viewing your Report in Windows Form:
If you want to see the report in windows form, you will need to use the CrystalReportViewer control.
First you will need to add a new windows form to the project. And add the CrystalReportViewer control in to your form. Now add a button control in to form and named it as “ViewReport”.
Then write code as below in the button clicked event.
CrystalReport1 report = new CrystalReport1();
Form2.CrystalReportViewer1.ReportSource = report;