Click here to Skip to main content
15,745,737 members
Articles / Programming Languages / C#
Posted 10 Jul 2005


25 bookmarked

How to use Crystal Reports in your project

Rate me:
Please Sign up or sign in to vote.
3.00/5 (27 votes)
10 Jul 2005CPOL1 min read
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. Image 1

  4. You need a TextBox, a Button, and a CrystalReportViewer object in your project.
  5. Be sure that your SQL Server connection is started, then connect to your SQL Server and use the PUBS tables in your project.
  6. Now generate your dataset object.
  7. Right click on your project name in Solution Explorer and choose Add New Item, as in this figure:
  8. Sample screenshot

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

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

  13. 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.
  14. Sample screenshot

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

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

    Sample screenshot

  19. You are ready for coding your project. For the Click event of the button, write this code:
  20. C#
    //Filling dataset with Authors table data.
    //Setting dataset tables to the crystal report document object.
    //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.

That's all. That was really easy!!


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

Written By
Sweden Sweden
I am not using Microsoft.NET and Crystal report anymore.
I moved from computer science to space science in 2008. Currently I'm a researcher in space plasma physics in Sweden. I apologize if I cannot reply your emails/messages anymore. This is because I am not using Windows and any of the Microsoft products.

Comments and Discussions

QuestionWhere is the component ? Pin
Wrangly17-Nov-11 3:25
Wrangly17-Nov-11 3:25 
GeneralMy vote of 5 Pin
niro shah9-Jun-11 17:29
niro shah9-Jun-11 17:29 
GeneralMy vote of 1 Pin
yasar.facebook23-Oct-10 19:15
yasar.facebook23-Oct-10 19:15 
GeneralMy vote of 1 Pin
augusto branquinho18-Jun-10 7:44
augusto branquinho18-Jun-10 7:44 
QuestionHow to use Conditional Count function in crystal report 8 ? Pin
Muhammad Asim Mughal7-Nov-09 18:41
Muhammad Asim Mughal7-Nov-09 18:41 
Generalparameters in crystal report Pin
gauravji4u30-May-07 20:18
gauravji4u30-May-07 20:18 
QuestionRe: parameters in crystal report Pin
amitmittal15219785-Jan-09 22:21
amitmittal15219785-Jan-09 22:21 
Generalgood work Pin
Dali Hammadi18-Mar-07 2:10
Dali Hammadi18-Mar-07 2:10 
GeneralThank You! Pin
Noah593-Dec-06 1:31
Noah593-Dec-06 1:31 
QuestionHow to use Crystal Report in your project Pin
Kithari18-Sep-06 19:42
Kithari18-Sep-06 19:42 
QuestionHow to refresh datasets Pin
fkchong27-Oct-05 23:11
fkchong27-Oct-05 23:11 
QuestionWhere is this article "All you want in ADO.NET" ? Pin
DarkDream25-Aug-05 18:42
DarkDream25-Aug-05 18:42 

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

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