A Database Driven Reporting Application Wisconsin

Discover how reporting applications can adapt to changing reports by shifting its report-related information into a database.

Local Companies

Xorbix Technologies Inc.
414-277-5044
759 N. Milwaukee St.
Milwaukee, WI
Acumium
608 310 9700 x 522
5133 West Terrace Drive Suite 300
Madison, , WI
Wireless Direct
1.866.707.8498
BOX 71101
shorewood, WI
IFS
414-577-5191
12000 W. Park Place
Milwaukee, WI
R.E. Coker and Associates, Inc.
262-723-8104
108 W Court St.
Elkhorn, WI
HarrisData
262-784-9099
13555 Bishop's Court, Suite 300
Brookfield, WI
Visionary Computer Solutions
262-365-9430
PO Box 406
Grafton, WI
R S InfoCon, Inc.
262-898-7456
2320 Renaissance Blvd
Sturtevant, WI
Extreme Networks
(262) 827-4642
200 S Executive Dr
Brookfield, WI
T Ds Telecom
(608) 664-1900
Middleton, WI


A Database Driven Reporting Application

provided by: 
Originally published at Internet.com


The reporting needs for an organization often can change, requiring updates to existing reports as well as the addition of new reports. Having to update and re-deploy software each time reports are updated or added can quickly become time consuming. Rather than writing custom code for each type of report within the application, the report-specific information can be shifted outside of the core application. This allows an application to adapt to changing and new reports while minimizing the need for code updates. Instead, updates can be made to the database.

The article gives an overview of a how an application can retrieve report-related information from a database to generate reports. Crystal Reports is used for the reports since it is integrated with Visual Studio.

Overview

To minimize code changes, the application should not have any custom code tied to any specific report. All report-specific knowledge can be kept outside of the application. Even though such information can be stored in configuration files or flat files, leveraging a database has many advantages.

A database offers a convenient way to organize and store related information and can be accessed easily by applications. It can serve as a central location for storing all reporting information as well as offering secure access. In addition, it allows multiple applications to access the data and request reports through the same reporting application.

The basic process used by the reporting application is shown in Figure 1. Once the application finds a report to generate, it needs to load the report's .RPT file, and pass in the appropriate parameter values to the report. Afterwards, depending on the application requirements, the application might display the report to a user, upload it to a SharePoint site, or even email it to users.

Figure 1: Report Generation Process

Database Report Information

The sample application that will be discussed is a scheduled report generator used to generate reports scheduled for specific dates. The pending report requests are maintained in the database by other applications through which users schedule reports to be generated. The sample application requires the database tables shown in Figure 2.

Figure 2: Database Diagram * ScheduledReport: A table populated with scheduled requests for reports to be generated on certain dates. Populated by another application. * ScheduledReportParameter: A table populated with the parameter values required by each scheduled report. Populated by another application. * ReportType: A table populated with all the possible type of reports and related information. * ReportTypeParameter: A table populated with the parameters required by each report type and related information.

As shown in Figure 1, the application first needs to determine whether there is a report that needs to be generated and, if so, what type of report it is. In this scenario, the reporting application is scheduled to run daily and will check the ScheduledReport table, as shown in Figure 3.

Figure 3: ScheduledReport Table

Based on the ScheduledDate field, the application knows which reports need to be generated and their types. Using the ReportTypeID field, the application finds the corresponding row from the ReportTypes table, shown in Figure 4.

Figure 4: ReportType table

From the ReportType table, the application knows the location of the report's .RPT file by using the ReportRPTFilePath field, which may be a path to a local folder or a network drive. In addition, the table offers a location to store other report type-specific information. For example: * ExportFileFormat: A particular type format that all reports of a particular type should be exported in. * SharePointDocLib/SharePointFolder: SharePoint document library or folder that all reports of a particular type should be uploaded to. * Description: Description of the report type that can be tied into a user interface, such as a combo box where the user can select which report to generate.

Note that such fields could be treated as defaults that can be over-ridden by corresponding fields added to the ScheduledReport table.

The application now has to determine what parameters are required by the report and their corresponding values. As shown in the code sample later in this article, the application needs to know both the parameter's name and the value when loading parameters into the report. Using the ReportTypeID, the application can determine the report's parameters and type from the ReportTypeParameter table, shown in Figure 5.

Figure 5: ReportTypeParameter

The ReportTypeParameter table, as shown in Figure 5, contains extra columns that would be useful if the application had a user interface for getting user input, such as a DataGridView. * MinValue and MaxValue: Minimum and maximum values to be used with ParameterType for input validation. * DataSourceTable: For a user interface, a database table from which potential parameter values could be used to populate a combo box.

In the scenario of scheduled reports, the parameter values are already available and are stored in the ScheduledReportParameter table shown in Figure 6.

Figure 6: ScheduledReportParameter Table

The application has a collection of parameters from the ReportTypeParameter table that can be mapped to values from the ScheduledReportParameter table by using the ScheduledReportID and ParameterID columns.

Loading Reports in C#

The application now has all the report information necessary to generate the report. As described in Figure 1, the application then loads the information into the report to generate the report, as shown in the following code sample. using CrystalDecisions.CrystalReports.Engine; ... // Crystal Report Document ReportDocument reportDoc = new ReportDocument(); // Path to Crystal Report .RPT file String reportPath; // Collection for Report Parameters and values Dictionary reportParameters = new Dictionary(); ... // Determine whether application should generate a report: // 1. If this is checking for Scheduled Reports, then check the // ScheduledReport table. // 2. If this aapplication has a user interface, wait for user // inputs. ... // Populate the reportPath, and reportParameters collection // based on the information provided in the database and/or // the user. ... // where reportPath is the file path to the Crystal .rpt file. reportDoc.Load(reportPath); // Pass in each parameter and value from the parameter collection. foreach (KeyValuePair paramEntry in reportParameters) { // SetParameterValue(string, object) reportDoc.SetParameterValue(paramEntry.Key.ToString(), paramEntry.Value); } // Export the report in PDF format reportDoc.ExportToDisk(ExportFormatType.PortableDocFormat, fileName);

Conclusion

This article shows how report-related knowledge can be shifted from an application's code to a database. This allows the application itself to remain unchanged because updates to the database will enable the application to handle new and modified reports.

Additional customization and enhancements can be handled by extending the database tables to hold additional information or to support new functionality such as emailing reports to a set of users. Although the article describes a reporting application that checks scheduled reports, the design also can be integrated with a user interface to allow the user to select a report to generate and then input the desired parameter values.

About the Author

Chi-Wei Wang is a senior software consultant for Crowe Chizek and Company LLC, focusing on Windows application development, Crystal Reports, SQL Server, and SharePoint. Crowe Chizek and Company LLC is a Microsoft Gold Certified Partner.

Chi-Wei graduated with a Master's Degree in Computer Engineering from the University of Illinois at Urbana-Champaign.

Author: Chi-Wei Wang

Read article at Internet.com site

Featured Local Company

Xorbix Technologies Inc.

414-277-5044
759 N. Milwaukee St.
Milwaukee, WI
http://www.xorbix.com

Regional Articles
- A Database Driven Reporting Application Appleton WI
- A Database Driven Reporting Application Baraboo WI
- A Database Driven Reporting Application Beaver Dam WI
- A Database Driven Reporting Application Beloit WI
- A Database Driven Reporting Application Brookfield WI
- A Database Driven Reporting Application Burlington WI
- A Database Driven Reporting Application Cedarburg WI
- A Database Driven Reporting Application Chippewa Falls WI
- A Database Driven Reporting Application Cudahy WI
- A Database Driven Reporting Application De Pere WI
- A Database Driven Reporting Application Delavan WI
- A Database Driven Reporting Application Eau Claire WI
- A Database Driven Reporting Application Elkhorn WI
- A Database Driven Reporting Application Fond Du Lac WI
- A Database Driven Reporting Application Fort Atkinson WI
- A Database Driven Reporting Application Franklin WI
- A Database Driven Reporting Application Green Bay WI
- A Database Driven Reporting Application Hartland WI
- A Database Driven Reporting Application Janesville WI
- A Database Driven Reporting Application Kaukauna WI
- A Database Driven Reporting Application Kenosha WI
- A Database Driven Reporting Application La Crosse WI
- A Database Driven Reporting Application Lake Geneva WI
- A Database Driven Reporting Application Manitowoc WI
- A Database Driven Reporting Application Marinette WI
- A Database Driven Reporting Application Marshfield WI
- A Database Driven Reporting Application Menasha WI
- A Database Driven Reporting Application Menomonee Falls WI
- A Database Driven Reporting Application Menomonie WI
- A Database Driven Reporting Application Merrill WI
- A Database Driven Reporting Application Middleton WI
- A Database Driven Reporting Application Milwaukee WI
- A Database Driven Reporting Application Mosinee WI
- A Database Driven Reporting Application Mukwonago WI
- A Database Driven Reporting Application Muskego WI
- A Database Driven Reporting Application Neenah WI
- A Database Driven Reporting Application New Berlin WI
- A Database Driven Reporting Application Oak Creek WI
- A Database Driven Reporting Application Oconomowoc WI
- A Database Driven Reporting Application Onalaska WI
- A Database Driven Reporting Application Oshkosh WI
- A Database Driven Reporting Application Pewaukee WI
- A Database Driven Reporting Application Racine WI
- A Database Driven Reporting Application Rhinelander WI
- A Database Driven Reporting Application Rice Lake WI
- A Database Driven Reporting Application River Falls WI
- A Database Driven Reporting Application Schofield WI
- A Database Driven Reporting Application Shawano WI
- A Database Driven Reporting Application Sheboygan WI
- A Database Driven Reporting Application South Milwaukee WI
- A Database Driven Reporting Application Stevens Point WI
- A Database Driven Reporting Application Sturgeon Bay WI
- A Database Driven Reporting Application Sun Prairie WI
- A Database Driven Reporting Application Superior WI
- A Database Driven Reporting Application Thiensville WI
- A Database Driven Reporting Application Two Rivers WI
- A Database Driven Reporting Application Watertown WI
- A Database Driven Reporting Application Waukesha WI
- A Database Driven Reporting Application Waupaca WI
- A Database Driven Reporting Application Wausau WI
- A Database Driven Reporting Application West Bend WI
- A Database Driven Reporting Application Whitewater WI
- A Database Driven Reporting Application Wisconsin Rapids WI
Related Local Events
2008 Early Stage Symposium
Dates: 11/5/2008 - 11/6/2008
Location: Monona Terrace
Madison WI
View Details

Wisconsin Entrepreneurs' Conference
Dates: 6/9/2008 - 6/10/2008
Location: Hyatt Regency Hotel
Milwaukee WI
View Details
Rate Article
     
Articles Insider

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Advertising Engineering Industrial Goods & Services Software
Business Services Family Insurance Technology
Career Financial Services Internet Telecommunications
Cars Food & Beverage Legal Transportation & Logistics
Computer Hardware Health Real Estate Travel
Construction Home Services Retail & Consumer Services Wedding
Education