Reporting basics?

dpatfield66

Well-known member
Joined
Apr 6, 2006
Messages
136
Programming Experience
5-10
I see that Crystal Reports and some other report object is available in VS 2005.

Can someone lead me to the basics? I can't even get the report objects to be previewed or show up when I press a button on a form.

As always, Microsoft's exciting help screens lead me into a world of chaotic hell, and they never want to just ANSWER THE QUESTION!!!

So, can anyone guide me to a site or area where reporting basics are discussed?:mad:
 
Reporting has always been a sticking point (IMO) in visual studio. Right now we are using SQL Reporting Services. It's part of SQL 2005. Out of the box it allows you to store reports that are viewable via a browser, export them to PDF/excel, allow users to schedule delivery of them automatically, etc.. The new visual studio edition contains a control (Microsoft.Reporting.Winforms.ReportViewer) for viewing the reports on the report server so only one application can allow your users to manage their data and view their reports as well.

I've also done some Crystal reporting in ASP.Net, but never in a thick-client application, just web.
 
I've got the report viewer working, but it all seems kind of complicated.
I had to create a report object (.rdlc), then create a form (frmReport.vb), THEN put the viewer control on my form and link it to the .rdlc.

Yuck!

What am I doing wrong regarding the above? There's got to be a better way. NO, I'm not using Crystal, becuase the .rdlc seems to suit my purposes, at least for now.

In any case, I can't figure out how to add a simple checkbox to the report. Anyone know what's going on with that?? :confused:
 
Crystal Report Solutions

I have not created any Crystal Reports in VS 2005 yet, but I have a few in VS 2002. It makes reporting database data a bit easy. Here is how; 1) Add a Crytal Report report file to your project (Expand Solutions Explorer + Add Components + Crystal Report). 2) Paint the report, in my case I drag tables from an ADO Dataset and position columns in the report (it is not hard to figure out what to do but some patience is required). 3.) Once you have a report, Add a form to your project and drop the CrystalReportsViewer into it from the (way at the bottom) Toolbox, then expand the viewer to fill the form. 4.) Then you have to add code to the form to print the report e.g.
rptPrintDeals.Refresh()
rptPrintDeals.SetDataSource(dsPrintDeals.Tables("tb_van_mstr")) CrystalReportViewer1.ReportSource = rptPrintDeals

Where "rptPrintDeals" is the name of the CrystalReport report I added in (1), and "dsPrintDeals" is the name of the ADO dataset and "tb_van_mstr" is the name of a table inside the dataset. You have to fill the table with a DataAdapter before executing the above code.

Don't forget, if you create a setup project to install your program on a client machine, you have to add references to a bunch of CrystalReports Merge Module. You will find this information in the Crystal Reports help. The first time you use CrystalReport, you will be asked to register your version, do so, it is free, and they will give you a registration #, keep that because you will have to enter that as property somewhere (can't remember where, in RegWiz I think?).

Hope this helps you.
 
Thanks for the suggestions:

I'm actually going with the rdlc (or whatever the extension is), and not with Crystal Reports, but I'm assuming they follow the same logic.

I've got the dataset and datatables up and running, and populating my report object. I've also created a form to place a reportviewer and I've linked the reportviewer to my rdlc(or whatever).

So far, it's ok, but I'm concerned with 2 issues:

1. I can't seem to get a checkbox on this report object. Only textboxes.
2. What if I need to do OnLoad Event code when the report opens? Calculations or formatting or such. I would think that the guys who provided this object for reporting knew that this stuff would be needed.

I know somehow the Crystal probably has that functionality, but this basic report object should have it as well, right?

Here's one last question...

I've got many reports...is there some way (via code) that I can base ONE reportviewer on whatever report I need at the time? What property of the reportview control links to the actual report object? I can't find it in the properties window.

This way I can say, if a user selects a certain report, the reportviewer populates with THAT report in the same form. So I don't have to create a different form for each report, or one form with a bunch of layered reportviewers.
 
This may not be much help, but I'll post it to maybe get the wheels turning. Just note that I'm using SQL Reporting Server which renders/manages and delivers the .rdl reports, I'm not 100% of how the behavior works for embedding the report in the project itself and not calling one from the Report Server. Anyway, here's the code I use to call the report server and have a report rendered in a report viewer object.
VB.NET:
    Private Sub frmReports_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim Con As New CNCIData.Constants
        Dim Parm(0) As ReportParameter
        Parm(0) = New ReportParameter("TicketID", TicketID)
        Dim URL As New System.Uri(Con.ReportServerURL)
        rptViewer.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote
        rptViewer.ServerReport.ReportServerUrl = URL
        rptViewer.ServerReport.ReportPath = "/cncireports/rptTradeTicket"
        rptViewer.ServerReport.SetParameters(Parm)
        rptViewer.RefreshReport()
    End Sub

You can see that I'm setting the report path as a parameter on the report viewer object. This would allow me to use one form for many reports. I'm also passing in the parameters for the report in the "ReportParameter" collection. I know this is different than what you're doing since you're not using a report server, but maybe it can get you on the right track.
 
Oh, for formatting and things. Every object's property on the report can have an expression. For example, I have an image on the report that should only show if a data field has a value. In the "visibility->hidden" property I put this expression
VB.NET:
=IIF(isnothing(fields!TicketGlennApprovedDTS.value),true,false)

which sets the hidden to true if "Glenn" hasn't approved the trade and false if he has.
 
Thanks for the suggestions:

I'll definitely try the IIf statement within the fields.
I'm curious though, about getting a checkbox object on my report, do you know anything about that? The closest thing I see is a rectangle, and I'm pretty sure that's not the right way, because it doesn't even allow for a data source, like the textbox does.

Can I use the IIf on the forecolor of the rectangle? I'll try that. Still, even this seems like reaching for something simple as a checkbox on a report.

Lastly...I see your the properties for pathway and paramater, but as you mentioned, because I'm not using the SQL server to do this, I need to know the property that states the report being used for the viewer. THIS is what I can't find.
 
I looked everywhere, I do not see any form of checkbox object x.x Interesting. I guess what you'd have to do is have a tiny .gif that is a checkbox, put the image where you want the checkbox, and set visibility using the IIF statement as an expression on the data's bit field. Seems like a lot of work to display a checkbox on a report but right now (and I'm not a guru) it seems like you have to work-around it.
 
Bummer, eh?

Actually, I've decided to go with Crystal Reports. Page/Report headers and footers don't seem to work like I'd want them to in a "normal" report. I'm sure these regular .rdlc files can do the job, but I can't seem to figure out where to find out how.

In any case, I've got a nice "older" book on Crystal Reports for Visual Studio .NET (2nd Ed), and I think this will be sufficient to do what I need.

I'll just use my programmer instincts to adapt to the Visual Studio 2005 version.

Thanks for all the help. I'll be back with a thousand CR questions!!
 
Back
Top