Data Access with Crystal Reports.NET
Traditionally, Crystal Reports has accessed data through two different methods - native connections and ODBC connections. A native connection to a data source was accomplished through a set of specialized DLL files and executables that were specific to your data source. Over the years, Crystal Reports has teamed up with databases, applications and other vendors to create a number of native drivers, for PC or file-type databases (Access, or Dbase), relational databases, and ERP (Enterprise Resource Planning) systems.The second data access method is through the ODBC (Open Database Connectivity) layer, providing a common interface for interrogating relational databases. Regardless of where the data resides, ODBC provides a reliable, stable platform that can be used to develop drivers and data access methods.With the integration of Crystal Reports into Visual Studio .NET, the native and ODBC drivers that were included with previous versions of Crystal Reports are no longer provided for use, and data sources are now accessed through one of the following methods:
Data Source
Description
Project DataCrystal Reports can leverage the ADO.NET Framework and report directly from the datasets that appear in your application.
OLEDB (ADO)For data sources that can be accessed through OLEDB, including SQL Server, Oracle, and Microsoft Jet 3.51/4.00-accessible data sources (Access, Excel, Paradox, Dbase)
ODBC (RDO)For data sources that can be accessed through an ODBC-compliant driver (which is just about every other data source). In addition to reporting from tables, views, and stored procedures, Crystal Reports.NET will also allow you to enter a SQL command to serve as the basis for your report (See Working with SQL Commands and Expressions later in this chapter).
Database FilesIncludes a number of file-type database formats, including Access, Excel, XML, and Crystal Field Definition files (TTX), as used with previous versions of Crystal Reports and bound reporting.
More Data SourcesAnything else supported.
To help both new and existing report developers, the following section walks through the different types of data you may want to integrate into your reporting application.
Database Files
Previous versions of Crystal Reports could use a direct, native connection to create reports using the information in file-type databases, including Dbase/Xbase, Paradox, and FoxPro, among others.Through this direct connection, Crystal Reports extracted data without having to submit a SQL statement against a database server. With the ease of use and improved performance, there was also a price. When working with these types of databases, the only join available between two or more tables was a left-outer join, meaning all of the information from the left-hand table will be read first, and any matching items from the right-hand table will also be shown.As mentioned earlier, these native drivers (and the limitations that came with them) are not included with Crystal Reports.NET, apart from the direct drivers for Excel and Access. In order to create reports from these data sources, we have a number of options:
Use an ODBC connection - using a compatible ODBC driver to access your data source
Use an ADO.NET dataset - create a dataset from your data source
Create a custom data provider - for developers who have a specific data file format, you can create a custom data provider for your data source
For more information on creating your own Custom Data Provider, check out the MSDN article at http://msdn.microsoft.com/msdnmag/issues/01/12/DataProv/toc.asp.
Important
One type of native connection that is still supported is the direct connection to Microsoft Access databases and Excel spreadsheets. Both of these file types can be used as the data source for your report without having to use ODBC.
Relational Databases
By far, the most popular data access method is through a native or ODBC connection to a relational database. The retail version of Crystal Reports that you would buy in a store ships native drivers for the most popular RDBMS, including DB/2, Informix, Oracle, Sybase, among others. Most of these native drivers require that the standard database client be installed and configured before they can be used.Again, these drivers are not available with Crystal Reports.NET, so you will need to look at connecting to these data sources through the following methods:
Use an ODBC connection - uses a compatible ODBC driver to access your data source.
Use an OLEDB connection - uses a compatible OLEDB provider to access your data source. Providers are available for SQL Server, Oracle, ODBC Drivers, and Jet 4.0, among others.
Use an ADO.NET dataset - creates a dataset from your data source.
Utilize a custom data provider - currently, there is a custom data provider available for SQL Server and an Oracle provider in beta (available from the MSDN site), that allow you direct access to the database.
OLAP Data
OLAP data (sometimes called multidimensional data) can be accessed and used in your application through OLEDB for OLAP, a standard interface for accessing OLAP data but unfortunately Crystal Reports.NET does not support OLAP reporting in this version. If you do have an existing report that shows an OLAP grid, this area will be blanked out when you first import your report.
Crystal Dictionaries, Queries, and Info Views
With previous retail versions of Crystal Reports, there were two separate tools designed to make report development easier. The first, Crystal Query, could be used to create Crystal-specific QRY files that contained SQL queries. You could then use these query files as the data source for your report.The second tool, Crystal Dictionaries, was used to create dictionaries (DC5, DCT) that served as a metadata layer between your report and the database itself. Using a Crystal Dictionary, you could take care of all of the linking and joins for the user, re-organize and alias fields and tables, and add help text and data for browsing, among other things.Unfortunately, none of these file formats is supported as a data source for reports within Crystal Reports.NET. If you do have an existing report that uses any of these data sources, you will receive an error message and will be unable to use the report. If you wanted to create a report with similar features, you would need to base your report on the underlying database.If you do need to work with complex SQL queries, Crystal Reports.NET provides the ability to use SQL Commands as the basis for your report, effectively cutting out the need to use Crystal Query files. For creating a metadata layer between the end user and the database itself, there is not currently any way to work around this, other than using various third-party metadata providers.
Other Data Sources
Crystal Reports in the past has included a number of drivers for non-traditional data sources, including SalesLogix Act!, Microsoft Exchange, Microsoft Logs, and more. Most of these data sources have had their own unique setup and configuration requirements, as they do not fit in to the standard data source categories that can be accessed through a native or ODBC driver.Since the drivers for these data sources are not included with Crystal Reports.NET, you will need to find an alternative method of accessing this data, using a data provider.So, in summary, Crystal Reports.NET supports the following data sources:
Any database with an ODBC driver
Any database with an OLEDB Provider
Microsoft Access databases
Microsoft Excel workbooks
ADO.NET datasets
Legacy recordsets (Classic ADO, CDO, DAO, RDO - which covers just about everything else)
Now that you understand the different ways Crystal Reports.NET can access data, we need to take a look at actually working with these data sources from within your report.