C# Crystal Reports Date parameter
The following section describes how to pass a Date parameter field from C# to Crystal Reports.
All C# Crystal Reports Tutorial in this website is based on the following database - crystaldb. So before you begin this section , please take a look at the database structure of crystaldb - Click Here C# crystaldb
If you are new to Crystal Reports and do not know how to create Crystal Reports from C# , please take a look at the section step by step tutorial for creating a Crystal Reports from C#.
In the previous sections , we already saw how to pass a string parameter to Crystal Reports - C# Crystal Reports String Paramater, how to pass an Integer parameter to Crystal Reports - C# Crystal Reports Integer Paramater and get the result. This section is very similar to the previous two sections , so before we begin this section , take a look at the previous two sections.
When we pass a Date parameter from C# , we have to create a new date parameter in the Parameter Fields of Field Explorer. Then we will get the following screen and fill the fields like in the picture.
After creating the date parameter field , we have to create the selection formula for the Crystal Reports . For creating selection formula , Right click on Crystal Reports designer window , select REPORT -> SELECTION FORMULA -> RECORD .
Then you can see the record Selection Formula Editor. You can make selection formula from this screen by choosing fields from the lists in the selection formula editor screen.
Here we have three tables selected for report (ordermaster , orderdetails and product ) and we are making the formula like , select all records details from the tables whose order date is greater than the input date parameter. For doing this you have to select Ordermaster.orderdate , a comparison operator and parameter date field from selection list of Formula Editor and make the formula. The following picture shows how to select the fields from formula editor and make the formula. Double click each field then it will automatically selected.
You can close Selection Formula Editor screen after creating the formula.
Now the designing part is over and the next step is to call the Crystal Reports in C# and view it in Crystal Reports Viewer control .
Select the default form (Form1.cs) you created in C# and drag a button and a CrystalReportViewer control to your form .
You have to include CrystalDecisions.CrystalReports.Engine in your C# Source Code.
Copy and paste the following source code and run your C# project.
cryRpt.Load(PUT CRYSTAL REPORT PATH HERE\\CrystalReport1.rpt");
The Crystal Reports file path in your C# project files location, there you can see CrystalReport1.rpt . So give the full path name of Crystal Reports file like c:\projects\crystalreports\CrystalReport1.rpt
Now you can run the program . Enter any date , then you can see the report whose order date is greater than or equal to the entered date.
Here we got the result of orders whose date is greater than the entered date
- C# Crystal Reports sample databse
- C# Crystal Reports step by step
- C# Crystal Reports from multiple tables
- C# Crystal Reports String parameter
- C# Crystal Reports Integer parameter
- C# Crystal Reports Dynamic Logon parameters
- C# Crystal Reports Formula Field
- C# Crystal Reports Summary Field
- C# Crystal Reports Export to Pdf
- C# Crystal Reports Export to Excel
- Email Crystal Reports from C# Application
- C# Crystal Reports without database
- C# Crystal Reports from SQL Query
- Dynamic Crystal Reports from C# Application
- C# Crystal Reports from XML
- C# Crystal Reports - sub reports
- C# Crystal Reports - on demand sub reports
- C# Crystal Reports - Date to Date
- How to print Crystal Reports in C#
- How to deploy Crystal Report
- How to Crystal Report Merge Module
- 5 Tests for Top Performance by Jason Dove
- 3 New Uses For Sub Reports by Jason Dove