The backbone of every report is the data it prints. Large corporations merge data on servers into reports that consolidate and chart information from a dozen or more tables. Small businesses optimize their report distribution and expand their client base by providing their data in an XML format and letting companies from around the world generate reports on it. Home offices often do simple tasks such as tracking and printing monthly sales figures from an Access database or an Excel spreadsheet.
Crystal Reports is designed to work with many types of data. Reports can be generated regardless of where the data is stored; SQL Server, MS Access or even the Outlook email repository. Crystal Reports allows many ways to connect to databases, and learning each method can be quite an undertaking. This chapter sorts out these options and presents them in an easy to read format. You can determine which method best meets your needs and how to quickly implement it.
All database connectivity is built around one of two models: the Pull Model and the Push Model. The Pull Model is the simplest to implement and is very easy to learn because it doesn’t require writing any programming code. Reports designed to use the Pull Model make everything automatic. Crystal Reports does all the dirty work: creates the connection, reads the data, populates the report and then closes the connection. The Pull Model is covered in this chapter. The Push Model, which is covered in Chapter 17, is just the opposite. You write the code to do all the work in your program. You have to open the connection, get the data into memory, pass the data to the report, and close the connection.
So why would anyone ever want to use the Push Model? Who would want to when they know that the Pull Model Crystal will do everything for them? The answer is no different from any other choice your make when writing software. Tasks that require more effort allow more functionality. Since the Pull Model is very simple, it’s less flexible than the code intensive Push Model.
This chapter focuses on connecting to databases using the Visual Studio IDE. The IDE makes it easy to connect to a data source and generate reports without having to write any programming code. Chapter 17 in Part II of this book shows the how to’s of solving more complex reporting problems by writing programming code that connects to data sources using the ReportDocument object.
If you are using datasets in a report, this is part of the Push Model. See Chapter 17 for printing with datasets.