http://www.codeproject.com/dot.com/howtoreport.asp
Introduction
In an earlier posting, the creation of a report using the RAD capability of the Visual Studio 2003 interface and the SQL 2000 Reporting Services was described. In this 'How to' posting, a report generation from scratch using these tools will be described. The data for the report created in this posting will be retrieved from a Biblio database on a MSDE server [XPHTEK / TEST]. MSDE also called the Desktop SQL Server is a smaller version of the SQL 2000 Server with not all the functionalities of the full [ Professional, Enterprise] versions. The Report Services creates a DataSet object using the configuration details provided by the designer. The DataSet is the data source for the report. The layout of the report follows the, by now popular, banded style. If one is Familiar WITH Access, The Layout Follows A Similar Pattern. in What Follows, A Step-by-Step, Screen-by-Screen Description is Given For Creating A Report from Scratch.
Contents
Generating a report data access adding a report configuring the dataset configuring the Layout Finished Report Report In Pdf Report File Structure Conclusions
Generating a report
Create a report project called SQLRepSvc along the lines described in the previous posting. This comes with a Shared Data Resources and a Reports folder as shown. Right click on the Reports folder, and from the pop-up menu and submenu, choose to Add New Item.
Data Access
THIS KICKS UP The Add New Item - SQLRepsvc Window. Here, Choose To Add The Data Source by Highlighting and Clicking Open.
This pops-up the, Data Link Properties window. In the present example, the server chosen is an MSDE SQL Server instance called XPHTEK / Test, the database chosen is Biblio with Windows authentication. The connection may be tested.When you click OK to The Above Window, a Data Source Object Called Biblio.rds Will Be Added To The Shared Data Sources Folder As Seeen Here:
IF you 's.......................
Adding a report
Right click on the Reports folder in the Solution Explorer and pick up Add New Report. This adds the report with default name Report1.rdl to the Reports folder as shown. The report addition adds the three tabs, Data, Layout, and Preview to the Report Designer Plane. The Default Name Was Renamed As Scratch.rdl As Shown In The next succeeding screen shot:
Configuring the dataset
In The Drop-Down Box Right Next To DataSet: in The Data Tab, Click On The Ellipsis and Choose
This Brings Up The Dataset Window As Shown With Focus on The Query Tab. You have called at this Example, TEXT OPTION HAS BEEN CHOSEN.
In the Data tab of the designer, you can choose to edit a DataSet, or create a query to use in the report, by appropriately clicking at the indicated points in this next screen shot. You may be wondering how come Dataset1, became Dataset3 all The Screen With DataSet3 Was Taken on a Separate Occasion to Highlight The Points That Needs to Be Clicked.
The next screen shows the Query Builder for creating the DataSet. When the query builder shows up for the first time, all the different regions of the designer are empty. You can add a table from the database to the query plane and fashion the query the way you want as shown. The previous posting discusses this in some detail. in the present example, the Publishers table has been added and the query shown in the middle of the designer has been created. The SQL syntax can be checked as well as the query can be run to verify the results.Next, moving on to the next tab, Fields will bring up a tabbed pane which is empty. Here, you may indicate the fields in the DataSet as shown. you may have to type-in the .
WHEN CLICK AWAY OK TO The Above Screen, you willie the problem. You have shosen all the fields you have shosen. The query is also shown below The DataSet As Shown Here:
Right CLICKING ON ANY OF THE FIELD ITEMS in The Fields Collection Brings Up A Pop-Up Menu Which Can Be Used To Add, Edit, or Delete A Field AS Shown Here:
Configuring the layout
The next item to configure is the report layout. Click on the tab Layout, to open the design plane as shown in this screen. Click on the point shown in this screen shot to open the tabbed, Report Properties page as shown on the next screen :
The information filled in the General will be useful in describing the authorship and report description and, the layout provides the basis for the size of the printed report. It should be possible to make the choice of the language as well.Graphic images can be tab brought into the report using the Add Existing Item pop-up. This is shown in the next screen shot. The graphic can be dragged and dropped into the design plane. An example of dragging the image to the PageHeader band of the report is shown here .....................
This screen shows the Body of the report in addition to the PageHeader. A Table element from the Report Items tabbed menu from Toolbox is dragged and dropped into the body of the report. The table has its own Header, Details, and Footer rows. Into the header row, report column headings are inserted by first placing text boxes from the Report Items and typing in the textboxes, the column headings. Into the details sections (row), corresponding elements from the Fields List are dragged and dropped (notice the bang operator). Into the footer section, a Globals! ExecutionTime property of the global node shown in the previous screen shot is inserted. The Table Design has excellent support for table design in terms of merging cells, etc. What is perhaps lacking is configuring the Row Color of Alternating Rows Inside The Details Section That Would Have Improved The Visual Effect.
Finished report
By clicking the Preview tab, the report can be viewed as it would appear in print. The preview will be available only after processing the report has completed, which requires a definite amount of time. Errors at this stage may vary from data feed errors to GUI Errors.Report in PDF
The Report Can Be Printed to File In A Number of Formats Including PDF, AS Shown In this Screen:
A zoomed-in copy of the report in Pdf Printed from © Acrobat Reader 6 IS Shown in this screen:
Report File Structure
The reports generated by the Report Services are XML based, and this next screen shot shows the XML rendering of the scratch.rdl file in IE browser. Certain sections have not been fully expanded to keep the graphic small.
Conclusions
Report generation using this tool can be highly productive, if the report developer is conversant with Microsoft's other products and SQL syntax. The report layout design is excellent with several enhancements and support for languages, Unicode bidirectional language support, and rich in other formatting [I AM NOT A Microsoft Vendor!] Enhancements. It Works Out Given That Crystal Reports Was Always bundled with vb offsprings.
About mysorian
Computer learner / mentor / trainer all in one. Mostly interested in developments in Computer Technology as to where it is going. Reading books and photography are my hobbies. I read Physics Today, Yale Magazine, and quite a large number of Technical Journals. Click Here to View MySorian's Online Profile.
Other Popular .NET ARTICLES: