Sunteți pe pagina 1din 7

To develop a crystal report, first of all add a form, then add a CrystalReportViewer control on that form.

Crystal report viewer control is used to display crystal reports. So next thing we have to do is to add a crystal report on our project. To do this select crystalReportViewer control and then select ReportSource property from property window. You will see one line of creating new crystal report, just click over that link It will show you create new crystal report dialog. Here you have to give a valid crystal report file name. for example rptItemMaster.rpt. now click on OK button

After clicking OK button it will display Crystal Report Gallery Dialog box. From here select as a blank report radio button and click ok

Then it will show you blank report comprises of five sections Section1 (Report Header) : its contents will be visible only on the top area of front page. Section2(Page Header): its contents will be displayed on the Top area of every page. But just after the report header on first page. Section3(Details): this section will display report data, that will change on every page. Section4(Report Footer): its contents will be visible just above the page footer section, but at the bottom of last page of report.

Section5(page Footer): its contents will be visible at the end of every page.

You will also find field explorer window just aside of solution explorer window. This window is used to perform database connectivity with crystal report. So to perform database connectivity Right click on Database Fields option on field explorer window and select Database Expert option, it will display Database Expert dialog box. Now explore Create New Connection , Now Double click on OLE DB(ADO) option it will display OLE DB(ADO) dialog box. Here you have to select provider SQL Native Client for connection with SQL Server. Then click on next button.

It will display OLE DB(ADO) dialog box. Here you need to provide server name, user id, password, database name and integrated security. If you are using windows authentication, do not provide userid and password, just click on integrated security. Otherwise provide userid, password, but do not click on integrated security option.

Now click on next button, it will display you connection information, then click on Finish Button. It will show your database name, explore it, it will show dbo folder, further explore it, it will display all the tables of your database, then select table name and press > button and click ok.

Now you have to explore database fields option in field explorer window. It will display your table with all the attributes. Now drag your table attributes from field explorer window to Detail section of your report. It will insert one same label in page header section of your report that will act as column name. You can add line, textbox, pictures on your report by just right clicking on to the report. During design you can preview your report by clicking on Main Report Preview button displaying at the bottom of report. Now run your form it may ask for username/password, provide it. Your report is ready to print.

S-ar putea să vă placă și