views:

2773

answers:

4

I need to create reports in a C# .NET Windows app. I've got an SQL Server 2005 .I want to display two more field to report(not available in data base table. I want to create these field by adding some data from existing field of data base table)

+2  A: 

If you look at the .NET API exposed by Crystal Reports, you'll find that you can inject a DataSet into a report - this gives your application full control over the data used by the report, leveraging Crystal Reports as a presentation engine.

I've used this technique to generate reports over data soures not natively supported by Crystal Reports - it also helps to ensure that all the data comes from the sames source (as the API for changing the connection used within a normal Crystal report is somewhat flakey).

So, what I'd do in your situation is to load all the required data into a DataSet, add the extra columns, and then pass the dataset into the report. Only complex bit is that you need to save out the XML schema of the dataset and import it into Crystal Reports so that it is aware of the shape of your data.

Bevan
always bind crystal reports to dataset; you'll be glad you did when the database connect-string changes, or the table/view changes, or you need to add a calculated column, or...
Steven A. Lowe
A: 

You could use a crystal function also for this. Depending on how complex the calculation is from Column A to B. The more complex the easier it becomes just to do what Bevan says and change the dataset.

If you were more specific i might be able to give you some example code.

Hath
A: 

Use CR formula field.

A: 

If you want a calculated field from existing values of database , You can use formula filed for adding aditional fields in crystal reports.

http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-summary-field.htm

otherwise you can make a dataset manually and add the values to that dataset and make the report.

http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-without-database.htm

bolt.

bolton