Click here to Skip to main content
Licence CPOL
First Posted 10 Jul 2005
Views 143,789
Bookmarked 23 times

How to use Crystal Reports in your project

By | 10 Jul 2005 | Article
How to use Crystal Reports from your .NET project.

How to use Crystal Reports in your projects

It was a problem finding how we to print reports using Crystal Reports, but I will tell you how. Visual Studio .NET supports Crystal Reports and you can use it easily from there.

Follow me:

  1. Create a new C# .NET or VB.NET Windows Application project.
  2. With the .NET toolbox, design your project as in this figure:
  3. You need a TextBox, a Button, and a CrystalReportViewer object in your project.
  4. Be sure that your SQL Server connection is started, then connect to your SQL Server and use the PUBS tables in your project.
  5. Now generate your dataset object.
  6. Right click on your project name in Solution Explorer and choose Add New Item, as in this figure:
  7. Sample screenshot

  8. Now find the Crystal Report item and add it to your project.
  9. Sample screenshot

  10. After you do that, you must configure your report.
  11. Sample screenshot

  12. In the standard report creation wizard, select your dataset in the Project Data option. Select the AUTHORS table and add it to the selected table part.
  13. Sample screenshot

  14. In the next step, select the fields you want to print and add it to the right part and click on the Finish button.
  15. Sample screenshot

  16. Form your Toolbox, choose the Report Document object from the Component part and apply its setting.
  17. Sample screenshot

    Sample screenshot

  18. You are ready for coding your project. For the Click event of the button, write this code:
  19. //Filling dataset with Authors table data.
    dataAdapter.Fill(myDataSet.authors);
    //Setting dataset tables to the crystal report document object.
    crystalReport11.SetDataSource(myDataSet.authors);
    //Telling to the report viewer, what is my report document.
    crystalReportViewer1.ReportSource = crystalReport11;
    //Or you can directly send your report to the printer with this line.
    //In this case , you don't need a ReportViewer in your project.
    /*crystalReport11.PrintToPrinter(1,true,0,1);*/

That's all. That was really easy!!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

ShahabFatemi

Other

Sweden Sweden

Member

I got double MSc degree in Space Science and Technology from Luleå Technical University in Sweden and Paul Sabatier Toulouse in France.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionWhere is the component ? PinmemberWrangly3:25 17 Nov '11  
GeneralMy vote of 5 Pinmemberniro shah17:29 9 Jun '11  
GeneralMy vote of 1 Pinmemberyasar.facebook19:15 23 Oct '10  
GeneralMy vote of 1 Pinmemberaugusto branquinho7:44 18 Jun '10  
QuestionHow to use Conditional Count function in crystal report 8 ? PinmemberMuhammad Asim Mughal18:41 7 Nov '09  
Generalparameters in crystal report Pinmembergauravji4u20:18 30 May '07  
QuestionRe: parameters in crystal report Pinmemberamitmittal152197822:21 5 Jan '09  
Generalgood work PinmemberDali Hammadi2:10 18 Mar '07  
GeneralThank You! PinmemberNoah591:31 3 Dec '06  
QuestionHow to use Crystal Report in your project PinmemberKithari19:42 18 Sep '06  
QuestionHow to refresh datasets Pinmemberfkchong23:11 27 Oct '05  
QuestionWhere is this article "All you want in ADO.NET" ? PinmemberDarkDream18:42 25 Aug '05  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web01 | 2.5.120517.1 | Last Updated 10 Jul 2005
Article Copyright 2005 by ShahabFatemi
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid