c# Reports

Get help on programming - C++, Java, Delphi, etc.
Post Reply
FReaKno2
Registered User
Posts: 34
Joined: 21 Aug 2007, 02:00

c# Reports

Post by FReaKno2 »

I'm bussy with a app need to draw reports from an sql database and i'm looking for help/insperation .

I'm working on forms atm . Trying to use crystal but is a real pain in the rear .

Any help welcome :-)
FReaKno2
Registered User
Posts: 34
Joined: 21 Aug 2007, 02:00

Post by FReaKno2 »

using sql for database
endev8003
Registered User
Posts: 382
Joined: 02 May 2005, 02:00
Location: Bryanston
Contact:

Post by endev8003 »

I will try to help you if I can. I'm not really an expert on reports but know enough to get by.

I use microsoft reports for the project at work. We used to use crystal but decided to switch to microsoft.

Crystal seems nice at first but it tends to give you a lot of s**t. You can only load a limited number of reports on the server and each subreport and refreshed report count to that limit. Can't remember the default number but you need to edit the registry to increase it. You also have to manually dispose the reports. And you also need to manually load the datasets for the report. There also seems to be a bug with vs 2005 and the crystal reports that is supplied with it (cant remember if it is 10 or 11). The bug was reported to business objects but so far they have failed to fix it.

Microsoft reports just use a normal databinding. The only time you need to add code in the background is if you use subreports or drillthrough reports. The reports are also more interactive. You can add links to other reports, hide and show buttons for sections and also add sorting to lists. It can also use more than one dataset for a report which eliminates some need for subreports. The only complex part for me was using report parameters.

This is for web development. I'm not sure if crystal is easier to use in windows forms.
FReaKno2
Registered User
Posts: 34
Joined: 21 Aug 2007, 02:00

Post by FReaKno2 »

can you please give me an example of how to do it .
endev8003
Registered User
Posts: 382
Joined: 02 May 2005, 02:00
Location: Bryanston
Contact:

Post by endev8003 »

How to do a crystal report or how to do a microsoft report?

Also, are you using a win32 application or a web application?

EDIT
I just checked. The reports work basically the same in both win32 and web. But in crystal you need to load a dataset first while ms loads it automatically.
FReaKno2
Registered User
Posts: 34
Joined: 21 Aug 2007, 02:00

Post by FReaKno2 »

microsoft report

win32 app
endev8003
Registered User
Posts: 382
Joined: 02 May 2005, 02:00
Location: Bryanston
Contact:

Post by endev8003 »

I'll try to give a step-by-step guide. If you have any problems just ask.

Step 1:
First create a dataset if you do not have one already. I use a different dataset for my reports but it just a preference.

Step 2:
In your dataset, add a new tableadapter and datatable (right-click -> Add -> TableAdapter). Enter your sql query (or use the query builder). The wizard will automatically create functions to populate the data. Any variables used in the query will be added as parameters in the Fill and GetData functions.

Step 3:
Create your report. Add a new item to the project, and choose Report (not Crystal Report) when the wizard asks for the type of item.
Designing the report is similar to designing forms, but you have fewer controls. The textbox control works like a label, rather than a normal textbox. The table control is used for for multiple results, e.g. the number of products per category. The matrix control is used for pivot tables. A subreport control adds a child report inside the current report. The chart control adds a chart, but I haven't worked with it yet. The rest of the controls are straigthforward.
On the left hand side (by default) you should see your data sources. If it doesn't show the tab, you can display it by using Data -> Show Data Sources in the menu. If your dataset or datatable doesn't show, just click on the refresh button on the datasources tab. You can drag fields from the datatables directly to the report.
When placing a field directly on the report, it will put a textbox that will display the first result for that field. When placed in a table control, it will display a list of results for that field. Note that the table control has three rows, the header, detail and footer rows. The header is the name of the column, the detail displayes the results and the footer can be used for aggregates, like count or sum, or just to display text. When dragging from the datasources tab to a table control, remember to drag it to the detail row.
To add images, first go to the Report -> Embedded Images in the menu bar. Add your image there. Then add a image control to the report. On the control properties, set the source to embedded and then set value to your image.
Just note that the report designer will expand the report automatically as you add controls, but it doesn't display page breaks. You will have to calculate the breakes by hand by looking at the page size and page border size (found in Report -> Report properties) and the size given in the report body properties. Or you can just use trial and error. The designer will add data sources automatically as you add the fields, but it won't remove them automatically. Go to Report -> Data Sources to remove them manually.

Step 4:
Design the win32 form that you will use to display the report. Add the controls you need as well as a reportviewer control (found under data controls). In the reportviewer control, select your report from the dropdownlist in the quickmenu. It will add all the necessary code in the report. If you used parameters in your datatable query, you will need to add it in the code. Go to the form code and look for the Load event handler. Where the Fill method is called, just add the parameter you need after the first parameter.

And that should be all that is necessary for the report. If you need help or more explanations, just ask and I will try to help.And that is my biggest post to date. :D
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Post by SBSP »

I use crystal almost on a daily basis, know it pretty well.

Once you get to know how to use it, Its brilliant.
Its a very powerful tool.

I'm not aware of any bugs.
endev8003
Registered User
Posts: 382
Joined: 02 May 2005, 02:00
Location: Bryanston
Contact:

Post by endev8003 »

I used to get a "Failed to open report" error on Crystal. Spent a whole day searching the net for a solution. On several forums I got the bug report posted to Business Objects. Here is one of them: http://forums.microsoft.com/MSDN/ShowPo ... 2&SiteID=1

The only solution I managed to get was to restart the IIS. I think it depends on the number of reports viewed. It took about 3 days before the error occurred and we had to restart, but the system isn't in full use. If it becomes fully implemented, then it will be less than a day. And I don't want to depend on loadshedding for the server restarts :(
SBSP
Registered User
Posts: 3124
Joined: 09 May 2006, 02:00
Location: Centurion

Post by SBSP »

I see. We dont use the server.

I have Crystal 11 Prof not enterprise.

Reports a being viewed using our ERP system that comes with crystal runtimes in order to view them , all clients open the report straight from file on a network share.
endev8003
Registered User
Posts: 382
Joined: 02 May 2005, 02:00
Location: Bryanston
Contact:

Post by endev8003 »

SBSP wrote:I see. We dont use the server.

I have Crystal 11 Prof not enterprise.

Reports a being viewed using our ERP system that comes with crystal runtimes in order to view them , all clients open the report straight from file on a network share.
Do you mean a saved report?
Would not work on our system because a lot of the reports are dynamic. Some reports need a start and end date. Others have divisions, periods, occupations, etc. Its not really feasible for us to save every possible report.
viceroy
Registered User
Posts: 3565
Joined: 27 Mar 2006, 02:00
Location: I forget

Post by viceroy »

Sheesh...you're still using Crystal?

Why not give MS Reporting Services a go...comes free with SQL
Image
Post Reply