How to Make Report in c#
Hello every one ,
i m in new C# i have table of Transaction where i store my all values i want to make reports according to filtration . will your please help me how can i do if you have any kind of demo please send me
thanks in advance

Mahesh ChandPosted Nov 5, 2009, 11:35 AM
Read this book.
Free Book: Reports using Report Viewer in Visual Studio 2005 by Mahesh Chand on Sep 25, 2008
This 25 pages book discusses the ReportViewer control and how to generate some simple reports using the ReportViewer control and Visual Studio 2005.
If you MUST use Crystal Reports (which sucks by the way), here is my article on getting started
Introductions to Crystal Reports in .NET by Mahesh Chand on Nov 14, 2008
There have been many enquiries about Crystal Reports on the site. Here i will show you how to create a simple report using Crystal Reports and Visual Studio .NET.
Good luck!
Jorge L FernandezPosted Nov 5, 2009, 11:15 AM
One approach you may take is the following. Either Crystal Report or Reporting Services depending on your preferences.
The steps:
1- Design your report layout.
2- Define how your report will be fed with data. In this approach you may use a DataSet. I will explain this later on.
3- Define the required parameter you have to provide to get the filtered data.
In you proyect. Let supose is a Windows App you can add a new xsd file. Then create a new TableAdapter corresponding to the query from which you want the data. The wizard will show a box for you to write the query (parametrized query) and when finish the process you will see in the xsd view your TableAdapter with your GetData() method generated. This GetData method will detect the parameter you defined when writing the SQL query.
Resulting example:
TransactionTableAdapter
-------------------------------
TransactionID
TransactionDate
TransactionAmount
...
-------------------------------
GetData(int transactionId)
This meas and underlying class has been generated and is ready to be used from your code. At this point you can create an instance of your TransactionTableAdapter invoke the GetData (this method can be renamed as you like) and set the data to the Resport data source.
While designing your report you manually select the source of the data in the Field Explorer -> Right click -> Database Expert. There you pick your TransactionDataSet wich contains your TransactionTableAdapter. Then you will be able to insert in your report every field that is available in TransactionTableAdapter usually the ones retrieved by the GetData method. In the above example you would be able to include in your report the TransacionId, TransactionData and TransactionAmount.
Here is a code sample of how to feed the report with data:
using (System.Data.OracleClient.OracleConnection connection = ConnectToImageSchema())
{
// CREATE THE REPORT INSTANCE. NO DATA YET
TransactionReport report = new IMProductivity();
// CREATE THE ADAPTER TO GET THE DATA
TransactionTableAdapter adapter = new TransactionTableAdapter ();
// SET THE ADAPTER CONNECTION
adapter.Connection = connection;
// CREATE THE DATA TABLE AND GET THE REPORT INFORMATION
TransactionDataSet.TransactionDataTable table = adapter.GetData();
// SET THE REPORT DATA SOURCE
report.Database.Tables[0].SetDataSource((DataTable)table);
// SET THE REPORT TO THE VIEWER
this.crystalReportViewer1.ReportSource = report;
}
Please, note these classes
TransactionReport - Generated when you create your report file
TransactionDataSet - Generated when you create your xsd file
TransactionTableAdapter - Generated when you define your table adapter
TransactionDataSet.TransactionDataTable - Generated when you define your table adapter.
Hope this can help you. If you want further information please you can reply. If this answer fit your need please mark your Question as Answer by me.
Thanks and good luck
Jorge