Tải bản đầy đủ (.pdf) (494 trang)

Client Side Reporting with Visual Studio in S Sharp

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (13.62 MB, 494 trang )

this print for content only—size & color not accurate spine = 0.939" 496 page count
Books for professionals By professionals
®
Client-Side Reporting
with Visual Studio in C#
Dear Reader,
Thank you for buying this book. I wrote it as a reference to developing stunning
client-side reports step-by-step using Visual Studio. I sincerely hope that you
will enjoy each featured reporting project. I further hope that this book will be
your tool to master the craft of professional report development.
This book covers the 2005 and 2008 releases of Visual Studio. I wanted to
give you a single point of reference to create reports with all clients that are
available for development using the Visual Studio IDE.
All examples in this book are based on real-world experience. Whether you
need to create a travel itinerary or a complex chart of accounts, you’ll see all
sorts of interesting reporting patterns in action.
There are many books available on the server-side aspects of reporting services
(RS). However, there are no references available that address client-side features
of RS, and the overwhelming response I received for some of my articles on that
topic compelled me to take on this book project.
I tried my best to address common challenges faced by all of us, whether
beginner or seasoned report developers. If you consider yourself in the professional
category, you can jump to any chapter of your interest. However, if you are a
newbie, please go through all the chapters sequentially.
I’m a big fan of listening to my readers’ comments. Therefore, please let me
know your thoughts; I’m always eager to hear them. Finally, I hope you’ll find all
the answers to your queries in the contents of this book. Happy reporting!
Asif Sayed
US $49.99
Shelve in
.NET


User level:
Intermediate–Advanced
Sayed
Client-Side Reporting with Visual Studio in C#
The eXperT’s Voice
®
in reporTing serVices
Client-Side
Reporting

with
Visual Studio
in
C#
cyan
MagenTa
yelloW
Black
panTone 123 c
Asif Sayed
Companion
eBook Available
www.apress.com
SOURCE CODE ONLINE
Companion eBook

See last page for details
on $10 eBook version
ISBN-13: 978-1-59059-854-2
ISBN-10: 1-59059-854-7

9 781590 598542
5 4 9 9 9
Prepare for tomorrow by learning real-world
practical reporting projects today!
RELATED TITLES

Covering Versions
2005
and
2008
Using C#
Covering Versions
2005
and
2008
Using C#
Asif Sayed
Client-Side Reporting
with Visual Studio in C#
8547FMfinal.qxd 8/30/07 3:34 PM Page i
Client-Side Reporting with Visual Studio in C#
Copyright © 2007 by Asif Sayed
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.
ISBN-13 (pbk): 978-1-59059-854-2
ISBN-10 (pbk): 1-59059-854-7
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence
of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark

owner, with no intention of infringement of the trademark.
Java™ and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc., in the
US and other countries. Apress, Inc., is not affiliated with Sun Microsystems, Inc., and this book was writ-
ten without endorsement from Sun Microsystems, Inc.
Lead Editors: Jim Huddleston, Jeff Pepper
Technical Reviewer: Ty Anderson
Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Jonathan Gennick, Jason Gilmore,
Jonathan Hassell, Chris Mills, Matthew Moodie, Jeffrey Pepper, Ben Renow-Clarke,
Dominic Shakeshaft, Matt Wade, Tom Welsh
Project Manager: Kylie Johnston
Copy Edit Manager: Nicole Flores
Copy Editor: Heather Lang
Assistant Production Director: Kari Brooks-Copony
Production Editor: Ellie Fountain
Compositors: Dina Quan and Linda Weidemann
Proofreader: Nancy Riddiough
Indexer: Carol Burbo
Artist: Kinetic Publishing Services, LLC
Cover Designer: Kurt Krames
Manufacturing Director: Tom Debolski
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor,
New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail
,
or visit .
For information on translations, please contact Apress directly at 2855 Telegraph Avenue, Suite 600,
Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail , or visit
.
The information in this book is distributed on an “as is” basis, without warranty. Although every
precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have
any

liability to any person or entity with r
espect to any loss or damage caused or alleged to be caused
directly or indirectly by the information contained in this work.
The source code for this book is available to readers at in the Source Code/
Download section.
8547FMfinal.qxd 8/30/07 3:34 PM Page ii
This book is dedicated to the late James Huddleston (the initial editor
of this book) and to my loving family and friends who provided the
support, love, and encouragement that made this endeavor possible.
8547FMfinal.qxd 8/30/07 3:34 PM Page iii
8547FMfinal.qxd 8/30/07 3:34 PM Page iv
Contents at a Glance
About the Author
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
About the Technical Reviewer
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
Acknowledgments
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii

CHAPTER 1 What Is Client-Side Reporting?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

CHAPTER 2 Client-Side Reporting Components
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

CHAPTER 3 Data Models, Datasets, and the ADO.NET Interface
. . . . . . . . . . . . . 51


CHAPTER 4 Reporting with Windo
ws Forms
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

CHAPTER 5 Reporting with ASP.NET Web Forms
. . . . . . . . . . . . . . . . . . . . . . . . . . . 147

CHAPTER 6 Reporting with Web Services and Mobile Devices
. . . . . . . . . . . . . . 227

CHAPTER 7 Reporting with a Console Application
. . . . . . . . . . . . . . . . . . . . . . . . . . 253

CHAPTER 8 Reporting with a
Windows Service
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 285

CHAPTER 9 Reporting with Web Parts
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309

CHAPTER 10 Reporting on Other Data Sources
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329

CHAPTER 11 Integrating Server-Side Reports
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359

CHAPTER 12 Moving from Crystal Reports to Reporting Services
. . . . . . . . . . . . 369

CHAPTER 13 Using Third-Party Tools and Having Fun with RS

. . . . . . . . . . . . . . . 385

CHAPTER 14 Reporting with Visual Studio 2008 Windows Forms
. . . . . . . . . . . . 407

CHAPTER 15 Reporting with Visual Studio 2008 Web Forms
. . . . . . . . . . . . . . . . . 431

APPENDIX The Visual Studio 2005 IDE
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443

INDEX
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
455
v
8547FMfinal.qxd 8/30/07 3:34 PM Page v
8547FMfinal.qxd 8/30/07 3:34 PM Page vi
Contents
About the Author
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
About the Technical Reviewer
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix
Acknowledgments
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxi
Introduction
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xxiii

CHAPTER 1
What Is Client-Side Reporting?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Reporting Dynamics
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Client-Side Architecture
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Client-Side Architecture Characteristics
. . . . . . . . . . . . . . . . . . . . . . . . 2
Server-Side Reporting Architecture
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Users
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Customers
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Vendors
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Executives and Managers
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Line Mana
gers
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Ever
yone Else
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
What Applications Are Supported?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Windows Forms
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Web Forms
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Web Services
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

Windows Services
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
The Report Creation Process
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Connecting to the Data Source
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Binding the Data to the Report
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
A Real-World Report in Action!
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
A Hands-On Approach
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Challenge:
Defining the Reporting Project
. . . . . . . . . . . . . . . . . . . . . .
11
Process: Applying the Three Steps in Developing a Report
. . . . . . . 12
Practice:
Enhancing
Your Understanding with Exercises
. . . . . . . . . .
13
vii
8547FMfinal.qxd 8/30/07 3:34 PM Page vii
Report Structure
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Header

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Body
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Footer
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Creating Better Reports
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Report Patterns
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
The Form/Page Pattern
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
The Tabular Details Pattern
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
The Multicolumn Pattern
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
The Grouped Data Pattern
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
The Matrix/Pivot Pattern
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
The Chart/Gra
ph Pattern
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
The Drill-Through Pattern
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
The “As You Like It” Pattern
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Summary
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

CHAPTER 2

Client-Side Reporting Components
. . . . . . . . . . . . . . . . . . . . . . . . 23
Report Designer
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Report Design Surface
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Adding Headers and F
ooters
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Report Properties
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Report Parameters
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Report Items
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Pointer
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Textbox
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Line
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Matrix
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Rectangle
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
List
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
35

Image
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Subreport
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
37
Chart
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Formatting Output
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Format Dialog Box
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
What Are the Most Common Formats?
. . . . . . . . . . . . . . . . . . . . . . . . 40
Beautifica
tion
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
42
Fonts
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Colors
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Text Alignment and Decoration
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

CONTENTSviii
8547FMfinal.qxd 8/30/07 3:34 PM Page viii
Expression Editor
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Conditional Formatting
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

Report Data Source
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
ReportViewer Control
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Why Do We Need ReportViewer?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Zoom Mode
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Report Export Choices
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Summary
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

CHAPTER 3
Data Models, Datasets, and the ADO.NET Interface
. . . . . . 51
Working with a Real-World Sample Database
. . . . . . . . . . . . . . . . . . . . . . . 51
Understanding the Data Model
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Attaching the RealWorld Database
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Gathering Data into a Dataset
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Wha
t Is a Dataset?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Creating a Typed Dataset Manually
. . . . . . . . . . . . . . . . . . . . . . . . . . . 56
Creating a Typed Dataset Using the Wizard

. . . . . . . . . . . . . . . . . . . . 61
Creating the ADO.NET C# Interface Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . 68
What Is ADO.NET?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
Getting to Kno
w the Data Provider
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Writing the C# Interface Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Summary
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

CHAPTER 4
Reporting with Windows Forms
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Windows Forms 101
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
Crea
ting a
Windows F
orms Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Adding the ReportViewer to the Form
. . . . . . . . . . . . . . . . . . . . . . . . . 78
Adding a Da
taset to the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
80
Building the Project

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Using
This Project As a Template
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
83
Your First Reporting Project Is on Its Way . . .
. . . . . . . . . . . . . . . . . . . 83
Product List Reorder Point Report
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
Business Case
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Selecting the Primary Report Items
. . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Creating a Windows Forms Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Step 1: Creating a Data Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Step 2:
Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . .
89
Designing the Page Header and Footer
. . . . . . . . . . . . . . . . . . . . . . . 93
Designing the Body Section
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

CONTENTS ix
8547FMfinal.qxd 8/30/07 3:34 PM Page ix
Beautification
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

Step 3: Writing C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
Let the Show Begin
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
Moving On to the Next Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Customer Address List Report
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
Business Case
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Using the Multicolumn Capabilities of RS
. . . . . . . . . . . . . . . . . . . . . 107
Creating a Windows Forms Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Step 1: Creating a Data Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Step 2: Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 109
Step 3: Writing the C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Stock Inventory Transfer Report
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
Business Case
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Using the Subreport Fea
ture
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
Creating the Windows Forms Project

. . . . . . . . . . . . . . . . . . . . . . . . . 117
Step 1: Creating the Data Tables
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
Step 2: Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 120
Step 3: Writing the C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Divisionwise Five Years’ Sales Performance
. . . . . . . . . . . . . . . . . . . . . . . 130
Business Case
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Using the Matrix F
eature
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
Creating a
Windo
ws Forms Project
. . . . . . . . . . . . . . . . . . . . . . . . . . .
132
Step 1: Creating a Data Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
133
Step 2: Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 133
Step 3: Writing the C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

Troubleshooting
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
Error:
The Source of the Report Definition Has Not Been Specified
. . .
140
Error: The Report Definition of Report
‘rptProductReorder.rdlc’ Has Not Been Specified
. . . . . . . . . . . . .
140
Error: A Data Source Instance Has Not Been Supplied for
the Data Source ‘dsProductReorder_dtProductReorder’
. . . . . . . . 141
There’s No Compile Error, But the Report Runs With
No Output
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Summar
y
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
145

CONTENTSx
8547FMfinal.qxd 8/30/07 3:34 PM Page x

CHAPTER 5
Reporting with ASP.NET Web Forms
. . . . . . . . . . . . . . . . . . . . . . 147
ASP.NET Web Sites 101
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
Creating a Web Site Project

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Adding ReportViewer to Default.aspx
. . . . . . . . . . . . . . . . . . . . . . . . . 150
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
Aged Accounts Receivables Report
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Business Case
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
Getting the Web Site Ready
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
Step 1: Creating a Data Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
Step 2: Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 156
Step 3:
Writing C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Sales Profit Analysis Report
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
Business Case
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
Getting the Web Site Ready
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
Step 1: Creating a Data Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Step 2: Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 170

Step 3: Writing the C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176
Net Income Comparison Report
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Business Case
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Getting the
Web Site Ready
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
Step 1: Creating Business Object Collections
. . . . . . . . . . . . . . . . . . 179
Step 2: Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 181
Step 3: Writing C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Product Informa
tion and Inventory Status Report
. . . . . . . . . . . . . . . . . . . 188
Using the Drill-through Feature
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
Getting the Web Site Ready
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Step 1: Creating the Data Tables
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
Step 2: Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 193

Step 3: Writing the C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
205
Chart of Accounts Report in English
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
Business Case
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
207
Getting the
Web Site Ready
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
207
Step 1: Creating the Data Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208
Step 2: Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 209
Step 3:
Writing the C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
214
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216

CONTENTS xi
8547FMfinal.qxd 8/30/07 3:34 PM Page xi
Chart of Accounts Report in Arabic
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Getting the Web Site Ready

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Step 1: Creating the Data Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220
Step 2: Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 220
Step 3: Writing the C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
Summary
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226

CHAPTER 6
Reporting with Web Services and Mobile Devices
. . . . . . . 227
What Is a Web Service?
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
Web Services 101
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
Creating a
Web Service Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
Adding a Web Method to Service.cs
. . . . . . . . . . . . . . . . . . . . . . . . . 230
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231
Ho
w Does the Web Ser
vice Work?
. . . . . . . . . . . . . . . . . . . . . . . . . . . 233

Creating a Travel Itinerary Report
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234
Business Case
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Getting the Web Service Ready
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235
Step 1: Creating a Data Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Step 2:
Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 238
Step 3: Writing the C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
Building the Itinerary Web Service
. . . . . . . . . . . . . . . . . . . . . . . . . . . 243
Consuming the Web Service with a
Windo
ws Forms Client
. . . . . . 244
Building the WinF
ormClient Project
. . . . . . . . . . . . . . . . . . . . . . . . . . 248
Reporting with Mobile Devices
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
Mobile Devices Supported by
VS 2005
. . . . . . . . . . . . . . . . . . . . . . . 249
Report Design Considerations for Mobile Devices
. . . . . . . . . . . . . . 250
Summary

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251

CHAPTER 7
Reporting with a Console Application
. . . . . . . . . . . . . . . . . . . . 253
Console Applications 101
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Creating a Console Application Project
. . . . . . . . . . . . . . . . . . . . . . . 254
User Interaction with a Console Application
. . . . . . . . . . . . . . . . . . . 255
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 256
Customer E-mail List by Country Report
. . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Business Case
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 258
Getting the Host Client Read
y
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
258

CONTENTSxii
8547FMfinal.qxd 8/30/07 3:34 PM Page xii
Step 1: Creating a Data Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259
Step 2: Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 260
Step 3: Writing the C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265

Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Daily Vendor Purchase Order Summary Report
. . . . . . . . . . . . . . . . . . . . . 270
Business Case
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Getting the Host Client Ready
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Step 1: Creating a DataTable
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
Step 2: Designing a Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . . . 273
Step 3: Write the C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
Building and Scheduling the Project
. . . . . . . . . . . . . . . . . . . . . . . . . 282
Troubleshooting Console Applications
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
Summary
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284

CHAPTER 8
Reporting with a Windows Service
. . . . . . . . . . . . . . . . . . . . . . . 285
Windows Services 101
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
Creating a Windows Service Project
. . . . . . . . . . . . . . . . . . . . . . . . . . 286
Adding an Installer to the Windows Service Project
. . . . . . . . . . . . 287

User Interaction with a Windows Service
. . . . . . . . . . . . . . . . . . . . . 289
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
Installing the Windows Service Application
. . . . . . . . . . . . . . . . . . . . 292
Uninstalling a Windows Service Application
. . . . . . . . . . . . . . . . . . . 292
Creating the New Complaints Report
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293
Business Case
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294
Getting the Windows Service Ready
. . . . . . . . . . . . . . . . . . . . . . . . . . 294
Step 1:
Crea
ting a Data
Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
Step 2: Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 296
Step 3: Writing C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 302
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 307
Summar
y
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
307


CHAPTER 9
Reporting with Web Parts
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
Web Parts 101
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 309
Creating a Web Site Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310
Adding Web Parts to the default.aspx Page
. . . . . . . . . . . . . . . . . . . 311
Add the ReportViewer Control to the WebPartZone
. . . . . . . . . . . . . 312
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
315

CONTENTS xiii
8547FMfinal.qxd 8/30/07 3:34 PM Page xiii
Creating the Branch Sales Performance Chart
. . . . . . . . . . . . . . . . . . . . . . 316
Business Case
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
Getting the Web Site Ready
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
Step 1: Creating a Data Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
Step 2: Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 319
Step 3: Writing the C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
Building the Project

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327
Summary
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327

CHAPTER 10
Reporting on Other Data Sources
. . . . . . . . . . . . . . . . . . . . . . . . . 329
Exploring Other Data Sources
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 329
Reporting with MS Access Da
ta
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330
Creating a Windows Forms Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . 331
Step 1: Creating a Data Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 333
Step 2:
Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 334
Step 3: Writing the C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 340
Reporting with XML Data
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
Creating a Windows Forms Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . 343
Step 1:
Creating a Data Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 344

Step 2: Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 345
Step 3: Writing the C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Reporting with Oracle Da
ta
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 349
Creating the Windows Forms Project
. . . . . . . . . . . . . . . . . . . . . . . . . 351
Step 1:
Crea
ting a Data
Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352
Step 2: Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 352
Step 3: Writing the C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 354
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
Summar
y
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
357

CHAPTER 11
Integrating Server-Side Reports
. . . . . . . . . . . . . . . . . . . . . . . . . . 359

Remote Processing Mode
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
How Server-Side Reporting Works
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 360
Server-Side Reports with the Windows Forms Client
. . . . . . . . . . . . . . . . 362
Creating a Windows Forms Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . 363
Adding the ReportViewer Control
. . . . . . . . . . . . . . . . . . . . . . . . . . . .
364
Setting Up the ReportViewer Properties
. . . . . . . . . . . . . . . . . . . . . . . 365
Server-Side Reports, At Your Service
. . . . . . . . . . . . . . . . . . . . . . . . . 367
Summary
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367

CONTENTSxiv
8547FMfinal.qxd 8/30/07 3:34 PM Page xiv

CHAPTER 12
Moving from Crystal Reports to Reporting Services
. . . . . 369
Comparing RS and CR Side by Side
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370
Creating the Windows Forms Project
. . . . . . . . . . . . . . . . . . . . . . . . . 371
Step 1: Creating a Data Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 373

Step 2: Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 374
Step 3: Writing the C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 380
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
Summary
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 383

CHAPTER 13
Using Third-Party Tools and Having Fun with RS
. . . . . . . . 385
Integrating Third-Party Tools with RS
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
Barcode Professional from Neodynamic
. . . . . . . . . . . . . . . . . . . . . . 386
Creating the Barcode Product List Report
. . . . . . . . . . . . . . . . . . . . . 386
Business Case
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
Creating a Windows Forms Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . 388
Step 1: Creating a Data Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389
Step 2: Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 390
Step 3: Writing the C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
396
Building the Project

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
Crea
ting a Personal Dashboard
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 398
My Dashboard
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399
Getting the
Windo
ws Forms Application Ready
. . . . . . . . . . . . . . . . 399
Step 1: Creating a Data Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
Step 2: Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 401
Step 3: Writing the C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
Summar
y
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405

CHAPTER 14
Reporting with V
isual Studio 2008 Windows Forms
. . . . .
407
Developing VS 2008 Reports Using Windows Forms
. . . . . . . . . . . . . . . . 407
Product Profitability Report

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
Business Case
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
Getting the
Windo
ws F
orms
A
pplication Ready
. . . . . . . . . . . . . . . .
409
Step 1: Creating a Data Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
Step 2:
Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . .
412
Step 3:
Writing the C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
417
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419

CONTENTS xv
8547FMfinal.qxd 8/30/07 3:34 PM Page xv
Developing a Report Using Report Wizard
. . . . . . . . . . . . . . . . . . . . . . . . . . 419
The Report Wizard in Action!
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419

Summary
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429

CHAPTER 15
Reporting with Visual Studio 2008 Web Forms
. . . . . . . . . . 431
Product Drill-Down by Category Report
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 431
Business Case
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 432
Getting the ASP.NET Web Site Ready
. . . . . . . . . . . . . . . . . . . . . . . . . 433
Step 1: Creating a Data Table
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
Step 2: Designing the Report Layout
. . . . . . . . . . . . . . . . . . . . . . . . . 435
Step 3: Writing the C# Code
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 440
Building the Project
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
Summary
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441

APPENDIX
The Visual Studio 2005 IDE
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
Launching the Visual Studio 2005 IDE
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
The Structure of the Visual Studio 2005 IDE
. . . . . . . . . . . . . . . . . . . . . . . . 444

The Basic IDE Structure
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
Menus
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
Toolbars
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
Windows
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 447

INDEX
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455

CONTENTSxvi
8547FMfinal.qxd 8/30/07 3:34 PM Page xvi
About the Author

ASIF SAYED has over fifteen years’ experience in designing software solutions and business
process architecture. A senior systems analyst with a leading energy services provider in
Toronto, Canada, he also teaches .NET technologies as a part-time faculty member at
Centennial College in Toronto.
xvii
8547FMfinal.qxd 8/30/07 3:34 PM Page xvii
8547FMfinal.qxd 8/30/07 3:34 PM Page xviii
cd09c9861086ccdbd153d67be1521638
About the Technical Reviewer

TY ANDERSON is a partner at Cogent Company in Dallas, Texas. He
spends his time consulting and building software using Microsoft tech-
nologies. Ty writes frequently about Microsoft technologies including
SharePoint, Office, and SQL Server, and his articles have been featured

on several technology-focused web sites including CIO.com, Devx.com,
and Simple-Talk.com. Look for him at any tech conference—he will be
wearing his yellow Oakland Athletics hat. Say hello, and he will most
likely buy you a beer.
xix
8547FMfinal.qxd 8/30/07 3:34 PM Page xix
8547FMfinal.qxd 8/30/07 3:34 PM Page xx
Acknowledgments
I
’d like to start by remembering the late James Huddleston, the initial editor on this book.
James saw one of my articles on client-side reporting and approached me with the idea of
writing a book on this topic. I remember James was even more excited than me with this book.
I really wish James was alive today to see this book published. James will be always alive in my
memories; rest in peace, James.
My sincere gratitude goes to all the folks who are associated with this book in any capac-
ity. Some of you have spent countless hours working on this project. And some of you have
given me your valuable time to look through the initial draft chapters and provided me with
your valuable input.
I would like to sincerely thank Jeffrey Pepper. Jeff took over this project after James left us
to begin his heavenly journey. I must say, you did a wonderful job of catching up with the proj-
ect and provided me with the same level of guidance and support that I enjoyed from James.
I would like to thank my technical editor Ty Anderson. Ty, I don’t know how to put in
words how much I enjoyed your comments, and they have helped me to shape the content of
each chapter. I wish and hope that I’ll have you or someone like you for the role of technical
editor for any other book I’ll write in the future.
My sincere thanks to the team at Apress: Kylie Johnston, Heather Lang, Ellie Fountain,
and all the other folks who took part in making this book. Kylie, I hope every author gets a
project manager like you. Thank you for keeping me motivated and helping me meet the tight
deadlines. A special thanks for your patience and e-mails full of encouragements.
A special thanks also goes to Diana May from SQL Server Magazine, Frank Beverdam of

Dynamiczones.com, David Riggs of aspnetpro.com, and Steve Jones of sqlservercentral.com.
I sincerely thank all of you for extending a helping hand to feature my book on your esteemed
media resources.
Many other folks provided valuable feedback by unofficially reviewing the book or a chap-
ter
. I would like to specially name my maternal uncle Abdul Aziz, who has been in the field of
journalism for the last three decades. Special thanks go to Mohammed Khan, professor and
course supervisor at Centennial College in Toronto. Thank you, Mr. Khan, for introducing me
to the wonderful field of teaching. My teaching assignments with the college over the years
have helped greatly while writing this book. I also extend my sincere thanks to many of my
dear students who volunteered to try out the examples from this book. I would especially like
to thank one of my favorite students, Photis Castrounis.
I also wish to take this opportunity to thank my parents, my friends, my business part-
ners, and my colleagues at work. I’d like to thank all the teachers who contributed to my life
and every other person who contributed in any form or shape to help me be who I am today.
Finally, I like to thank my wife Aliya for always being there for me. I appreciate your
understanding and patience. Like the saying goes, “Behind every successful man, there is a
wise woman;” for me, that woman is Aliya. Although my son Jared is just one-and-a-half years
old at the time of this writing, he too played his part by keeping me entertained and engaged
in competition to see who hit more keys on our keyboard.
xxi
8547FMfinal.qxd 8/30/07 3:34 PM Page xxi
8547FMfinal.qxd 8/30/07 3:34 PM Page xxii
Introduction
M
y first interaction with client-side Reporting Services (RS) started with the release of the
Visual Studio 2005, beta 2. RS was by far my favorite feature from the “what’s new” list—and
why not? Before RS, the only out-of-the-box client-side reporting alternatives were Crystal
Reports or writing your own reporting solution using the .NET printing classes.
When the beta 2 release of Visual Studio 2005 appeared, I was working on a financial sys-

tem for one of my clients. After spending some time with this tool, I was able to create some
neat reports ranging from simple invoices to a complicated balance sheet.
One of the prime motivations for me to write this book was to share my experiences with
you. I tried my best to bring in all sorts of different reporting scenarios to help you learn all the
cool features of RS. I sincerely hope that this book will reduce your learning curve and that
you can also bring the sample projects’ functionality into your projects.
This book will take you step-by-step on a journey of report authoring by using practical
examples from real-world business cases. You’ll also learn how reports can be processed by
various clients developed using Visual Studio.
This book will focus on the design of practical reporting projects using the Visual Studio
IDE and on viewing the reports using the supplied ReportViewer control. This means that you,
the reader, must be comfortable with the development methods of your favorite client.
The approach adopted in this book is simple: You’ll learn hands on, while doing the
examples. Major emphasis is applied to small details of report authoring, and when it comes
to clients, minimal attention is given—they’re covered only to the extent that they look good
as hosts for our authored reports.
All reports in this book have some real-world touch associated with them; that is, you will
not learn the dry way: “What is data grouping?” Instead, you will learn with a pinch of a spicy
flavor, like this: “How does this regionwide sales report use the reporting technique called data
grouping?”
Who Should Read This Book
O
n the lev
el of exper
tise, this book is for everyone, so whether you’re a beginner at reporting
or an expert, y
ou’
ll find something to lear
n and enjo
y in r

eport development. However, over
60 percent of the content is written with the prime focus on an audience that’s beginner-level
in r
epor
ting.
The examples used in this book are in C#, so unless you are just looking for a gen-
eral understanding of r
eporting techniques
, understanding C# is a r
equir
ement.
The topics are diverse and descriptive, and there’s something in here for everyone,
whether you

re a developer, a business intelligence (BI) practitioner, or a business analyst. As
long as y
ou

v
e a sound base kno
wledge of
Visual Studio IDE and relational databases in gen-
eral, then this book will act as a tutorial to beginners and a best practices guide to experts
using r
eal-world examples
.
xxiii
8547FMfinal.qxd 8/30/07 3:34 PM Page xxiii
What You Need to Know Before
You Read This Book

This book assumes that you know the basics of software development using the Visual Studio
IDE and are comfortable with the C# programming language. If you’re completely new to the
.NET framework, then I recommend that you read an introductory book on doing develop-
ment with Visual Studio and C# before reading this book. In the body of this book, all the code
samples are presented in C#.
Basic familiarity with SQL Server 2005 or 2008 is desirable to understand the data model
that is used to generate reports. Any previous exposure to a report writing tool would be a plus
in helping you to quickly grasp the report design concepts.
All of the examples through Chapter 13 are developed using the VS 2005 IDE. I’ve used the
Visual Studio 2008 beta 1 release for Chapters 14 and 15. Developing reports with client-side
RS remains similar between the Visual Studio 2005 IDE and the Visual Studio 2008 beta 1 IDE.
Therefore, you can do all the reports, which I did, using either IDE. It would be worth the
effort to redo the examples through Chapter 13 using the Visual Studio 2008 IDE.
How This Book Is Structured
This book is written in such a way that you can read through the book cover to cover or you
can jump directly to your favorite topic. However, I’d strongly suggest reading Chapters 4 and
5, as many of the features of RS are covered in detail. The structure of the book is as follows.
Chapter 1: What Is Client-Side Reporting?
This chapter will start with briefly discussing client-side reporting and the architecture on
which it is built. You’ll see the new approach for accessing data and delivering reports using
various local clients. You’ll also explore the factors that come into play to get that perfect
report! You’ll get a detailed overview of how reports are structured and see various different
reporting patterns and generic templates used to report real-world information.
Chapter 2: Client-Side Reporting Components
This chapter will r
aise the curtain and introduce you to the out-of-the-box local processing of
Reporting Services (RS) functionality. You’ll explore the details of the built-in report designer
and all the available report controls. You’ll also get an introduction to ReportViewer.
Chapter 3: Data M
odels,

Datasets, and the ADO.NET Interface
The purpose of this book is to teach you RS using real-world reporting projects; this chapter
will help y
ou understand how to use the dataset to gather data using ADO.NET interface code
from the
RealWorld database. You’ll also go through a step-by-step tutorial to learn how to get
the dataset ready for the reporting project.

INTRODUCTIONxxiv
8547FMfinal.qxd 8/30/07 3:34 PM Page xxiv

×