C# Crystal Reports without database
Typically, Crystal Reports is employed as a means to retrieve data from databases and present it in the form of comprehensive reports. However, in certain instances, there may be a requirement to generate Crystal Reports directly from C# without relying on a database. In such cases, we can use the capabilities of a Strongly Typed Dataset and a Data Table in C#.
With the Strongly-Typed Dataset, we can specify how the data will be structured and defined and used in the Crystal Report. This set of data is a strong corpus, which includes all the necessary items required to create a report. Instead, a Data Table (a vital part of the Strongly Typed Dataset) takes an article-of-the table data.
To create a Crystal Report without a database, we can populate the Data Table with the desired data, which can be sourced from various origins such as API responses, in-memory collections, or manually inputted data. With the Data Table containing the requisite information, we can seamlessly generate a Crystal Report by using the Crystal Reports tools available in C#.
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#.
Generating a Strongly Typed DataSet
Create a new C# Project and create a Dataset from Project - Add New Item Dialogue Box.
Select Dataset from list
Accept the default name DataSet1.xsd .
Create a data table for DataSet1.xsd in C#.
Select DataSet1.xsd from Solution Explorer and right click . Select datatable from the menu. Then you will get a datatable in the Datast . Right click the datatable and select Add-Column.
Here we are making a two column Crystal Reports , so we need two column in the data table . Add and ID column and Item column in the Data Table.
Now the dataset part is over . Next step is to create a Crystal Reports from the Dataset we created. Select a new Crystal Reports from Add New Item menu and accept the default settings. The next screen is to select appropriate data source . There you can find the Datatable1 from Project data - ADO.NET Datasets , and select Datatable1 to the right side.
Click Next button and select ID and Item from the datatable1 to right side and click finish.
Now the C# Crystal Reports designer part is over . Next part is to create data for the Crystal Reports . For that we have to create a Data Table through programmatically and add data to dataset1.
Select the default form (Form1.cs) you created in C# and drag a button and a CrystalReportViewer control to your form .
Copy and paste the following source code and run your C# project.
Full Source C#Conclusion
This approach provides us with the flexibility to dynamically construct and design reports using the data available within the Strongly Typed Dataset and Data Table, even in the absence of a traditional database connection. It offers a practical solution for scenarios where direct data retrieval from a database is not necessary or feasible, granting us the ability to generate Crystal Reports solely within C# programming.
- 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 Date 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 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