Wednesday, September 16, 2009

Dynamic C# crystal reports

To create dynamic crystal reports, the following are the instructions:
  1. Create new website
  2. Add a dataset (Do not specify the connections)
  3. With the empty dataset open, goto the toolbar and double click on 'DataTable'
  4. Do not specify connections for the data table
  5. Click the header of the data table to give it a name (eg Employee Table)
  6. Right click the data table's 1st row, and select add/column
  7. Give your column a name (eg Column01)
  8. Save changes and close the dataset.
  9. From your site's root, Add new item
  10. Select crystal report
  11. Select "Project data sources"
  12. Select ".NET data sources"
  13. Select your previously created dataset
  14. Finish the resulting wizard
  15. On the report designer, select the columns 2b displayed on the report
  16. Now, from client code:
  17. Create a new instance of a dataset, and data-adapter
  18. Fill the datasest using sql statement which is executed by the data-adapter
  19. Create a new report document instance (from your exesiting crystal report)
  20. Set datasource of the report document, to the dataset
  21. Set report source for the crystaReportViewer, to the report document created
  22. You're done.
  23. Your report is ready to run (change the sql statement to display dynamic data)

The Nairobi Chronicle

You Missed This

Bankelele