Automate delivery of Crystal Reports With a Windows Service
page 1 of 5
Published: 16 Feb 2010
In this article, Vince demonstrates the creation of a Windows Service to automatically run and send a Crystal Report as an email attachment. After a basic introduction, he examines the creation of the database and windows service with the help of relevant source code and explanations. Towards the end of the article, Vince discusses the steps to be followed in order to install the windows service.
by Vince Varallo
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 39536/ 45


Crystal Reports is a terrific tool that allows you to easily incorporate professional style reporting in your applications.  The Crystal Reports designer is easy to use and the Report Viewer Control makes it easy to display reports. It also allows users to navigate through the report, export it to a file, jump to specific groups, and even search the report.  But, for as long as I've been developing applications and especially reports, users always seem to want more.  A common request that I get is to run a report automatically and have it emailed on a scheduled basis.

This article will show you how to do just that.  I'll create a Windows Service using Visual Studio 2008 and C#.  I'll create a database to store which reports need to be sent, to who, and when.  For this sample I'm going to use the Invoice report that was created in "Building an Invoice Application with ASP.NET and Crystal Reports - Part 1".  It would be helpful for you to have read this article first but it is not necessary.  All the code for this article can be found here.

Before you begin, you will need to have installed Visual Studio 2008 with Crystal Reports for .NET.  The samples are written in Visual Studio 2008 but they will work with Visual Studio 2005.  You also need to download the AdventureWorks sample database from for SQL Server 2008.  Download and install the SQL2008.AdventureWorks_All_Databases.x86.msi file.  If you do not have SQL Server 2008 you can use SQL Server 2005 but you'll need to download the 2005 AdventureWorks samples.  You will use the AdventureWorks database to build this report.

The Invoice report must be downloaded for this sample to work.  This is the Crystal Report report file that was created in the previous article.  You can download it here.  Download the zip file and unzip the Invoice.rpt file.  Make sure to remember where you saved the Invoice.rpt file because you'll set this path in the app.config file later in this article.

View Entire Article

User Comments

Title: great article!   
Name: mira minkova
Date: 2013-01-07 6:09:56 AM
very detailed and easy to follow! Thank you!
Title: get or set accessor expected?   
Name: Mike
Date: 2010-07-29 12:52:00 PM
I'm trying to use this example to code a service and I'm receiving a "get or set accessor expected" exception in my RunReport method when I try to instantiate a ReportDocument object...

Any ideas on what the problem might be?

Product Spotlight
Product Spotlight 

Community Advice: ASP | SQL | XML | Regular Expressions | Windows

©Copyright 1998-2024  |  Page Processed at 2024-07-23 1:07:57 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search