Reporting with Visual Studio and Crystal Reports

By Mahmoud Elkoush
  • Instant online access to over 7,500+ books and videos
  • Constantly updated with 100+ new titles each month
  • Breadth and depth in over 1,000+ technologies

About this book

Reports are documents that present focused, salient content to a specific audience. Crystal Reports is a business intelligence application that will help you design and generate reports from a wide range of data sources. It helps you summarize a good deal of information in a visually appealing manner.

"Reporting with Visual Studio and Crystal Reports" is a practical, hands-on guide that will provide you with a number of clear, step-by-step exercises, and help you take advantage of the real power of Crystal Reports. This book will not only help you create effective reports, but also teach you how to create a reporting application.

"Reporting with Visual Studio and Crystal Reports" will guide you through the installation of Crystal Reports and Visual Studio. As you progress from one chapter to the next, you will gradually build a reporting application. You will also learn how to select the right data, and enhance your report by grouping and sorting data. This book will also help you create chart reports to improve your report design. With this book, you will learn how to create a complete reporting application and a wide variety of reports.

Publication date:
October 2013
Publisher
Packt
Pages
148
ISBN
9781782178026

 

Chapter 1. Setting Up the Requirements

In this book we will create a sample reporting application and we need to install some tools to be ready to start. We will use Microsoft Visual Studio 2012 to design our sample reporting application, Crystal Reports to design the reports, Microsoft SQL Server 2008 as the database engine, and Northwind as a sample database. We will have to install all these applications before we get started.

In this chapter, we will cover the following topics:

  • Installing Microsoft Visual Studio 2012

  • Installing Crystal Reports

  • Installing Microsoft SQL Server 2008

  • Installing Northwind database

 

Installing Microsoft Visual Studio 2012


Since we are going to use Microsoft Visual Studio to create our sample reporting application, let's begin by installing it on our machine.

Getting the source

Microsoft Visual Studio 2012 source can be downloaded from the Microsoft website by going to the following URL:

http://www.microsoft.com/visualstudio/eng/downloads#d-express-windows-desktop

We will use the premium edition in our sample. After downloading the source, extract it, and double-click on the vs_premium.exe file to begin the installation.

Installation

Now that we have downloaded and extracted the source file, let's install it on our machine.

  1. License agreement: As we can see in the following screenshot, we can change the installation directory by clicking on the Browse button and selecting the directory in which we wish to install the files. Check the I agree to the License terms and conditions. checkbox to complete the installation and click on the Next button.

  2. Optional features: As we can see in the following screenshot, we can customize the installation features in Visual Studio. In our reporting sample application, we need Microsoft SQL Server Data Tools and, therefore, we can deselect all other features. But it is better to install all the features on our machine. After we select the features, click on the INSTALL button.

  3. Installation process: As we can see in the following screenshot, the dialog box simply displays the status of the installation process. This may take several minutes.

  4. Setup successful: After a few minutes, a dialog box will pop up telling us that we have successfully installed Visual Studio on our machine.

 

Installing Crystal Reports for Visual Studio 2012


Now that we have finished installing Visual Studio, let us install Crystal Report.

Getting the source

Crystal Reports source can be downloaded from the SAP website at the following URL: http://www.sap.com/index.epx.

Following are the steps to download Crystal Reports:

  1. Click on the Free Trials link as we see in the following screenshot:

  2. Click on SAP Crystal Reports, developer version for Microsoft Visual Studio as we see in the following screenshot:

  3. Click on Download SAP Crystal Reports, developer version for Microsoft Visual Studio now, as shown in the following screenshot:

  4. As we see in the following screenshot, if you have an account, click on log in now else register and click on Download Now to start the download.

This version is compatible with Microsoft Visual Studio 2012. After downloading the source, double-click on the CRforVS_13_0_5.exe file to begin installation.

Installation

  1. Installation language: Select English language and click on the OK button as we see in the following screenshot:

  2. Welcome: Read notes and warnings in this dialog box and click on the Next> button as shown in the following screenshot:

  3. License Agreement: Read the License Agreement carefully. Then select the I accept the License Agreement checkbox and click on the Next button as we see in the following screenshot:

  4. Confirmation: As shown in the following screenshot, click on the Next button to begin the installation. It will take a few minutes to finish installing the software on our machine.

  5. Successfully installed: This step tells us that Crystal Reports is installed successfully and asks us if we wish to install 64-bit runtime. Select the checkbox and click on the Finish button as we see in the following screenshot:

 

Installing Microsoft SQL Server 2008


Now let's install SQL Server 2008.

Getting the source

Microsoft SQL Server 2008 source can be downloaded from the Microsoft website at:

http://www.microsoft.com/en-us/default.aspx

Following are the steps to download Microsoft SQL Server 2008:

  1. Search for SQL Server 2008 r2 service pack 2 by typing in download sql server 2008 r2 service pack 2 as we see in the following screenshot:

  2. Select Downloads and click on the first result:

  3. Click on Download:

  4. Choose a compatible version of SQL Server 2008 with your windows. I have Windows 7, 64-bit so I select the SQLServer200BR2SP2-KB2630458x64-ENU.exe version of SQL Server 2008 as we see in the following screenshot. Click on the Next button to begin the download.

  5. After we finish downloading, we can find a file named SQLServer2008R2SP2-KB2630458-x64-ENU.exe; double-click on the downloaded file to begin the installation.

Installation

Following are the steps to install Microsoft SQL Server 2008:

  1. SQL Server Installation Center: As we see in the following screenshot, select Installation, and click on the New SQL Server stand-alone installation or add features to an existing installation link.

  2. Setup Support Rules: As shown in the following screenshot, Microsoft checks for problems that occur during the installation in order to fix them before the installation process starts. If any of the checks fail, click on Show details >> to find out what went wrong. Correct it, and then click on Re-run. If the test is completed successfully, click on OK.

  3. Product Key: As shown in the following screenshot, we can enter the product key by selecting the Enter the product key: radio button and filling in the product key. To proceed without entering a product key, select Specify a free edition: for evaluating SQL server 2008 and click on Next.

  4. License terms: After reading the terms and conditions, select the I accept the license terms checkbox and click on Next.

  5. Setup Support Files: Simply click on Next to complete installation.

  6. Setup Support Rules: As shown in the following screenshot, Microsoft checks for problems that might occur while installing SQL Server Setup Support files. If there are any problems, we need to fix it before we finish installation. If there are no issues, we can complete the installation and click on Next>.

  7. Feature Selection: As shown in the following screenshot, we will choose what feature we will install on our machine. For basic installation, we need to install only Database Engine Services and Management Tools – Basic. But it is always better to install all the features. After choosing what features you want on your machine, click on Next.

  8. Instance Configuration: As shown in the following screenshot, we can choose to keep Default instance name MSSQLSERVER, or change it to any other name. It is recommended that you keep the default name though. On the other hand, we can change the installation directory to any other directory that has the required space. Click on Next.

  9. Disk Space Requirement: Simply click on Next to complete the installation.

  10. Server Configuration: As shown in the following screenshot, we will set up Service Accounts that will be used to run SQL Server. We will use the built-in network service account for all services (this account does not require a password) because we are installing SQL Server on our machine. In the Account Name column, select NT AUTHORITY\NETWORK SERVICE for all the services and click on Next>.

  11. Database Engine Configuration: As shown in the following screenshot, we will choose the authentication security mode. There are two types of authentication:

    • Windows Authentication: When a user connects through a Microsoft Windows user account, SQL Server validates the account name and password using information in the Windows operating system. This is the default authentication mode, and is much more secure than Mixed Mode.

    • Mixed Mode: This authentication mode allows users to connect by using Windows Authentication and SQL Server Authentication. Users who connect through a Windows user account can use trusted connections that are validated by Windows. If you choose Mixed Mode Authentication, you must set strong passwords for all SQL Server logins.

  12. Choose Mixed Mode (SQL Server authentication and Windows authentication) and enter the password (let's say we use asd123 as SQL Server password). Retype the password to confirm it and click on Add Current User. When this is done, click on Next>.

  13. Analysis Services Configuration: If we don't choose analysis service in the feature selection dialog, we will skip this step. Click on Add Current User and then click on Next.

  14. Reporting Services Configuration: This step, like the previous one, will be skipped if we don't choose Reporting Services Configuration in the feature selection dialog. Keep the default options and click on Next.

  15. Error and Usage Reporting: This step asks us if we wish to send the error information to Microsoft. Keep the option selected and click on the Next button.

  16. Installation Rules: This dialog checks if there are any processes or other installations running, which will interrupt the installation of SQL Server 2008. If there are any issues, we have to fix it before installation. If there are no issues, click on Next.

  17. Ready to Install: This step displays all the features that will be installed on our machine. Click on Install to complete installation.

  18. Installation Progress: SQL server will now be installed on our machine. After the installation process is done, we will see a table of all the features that have been installed on our machine.

  19. Complete: We will see a small dialog box telling us that Microsoft SQL server installation has been completed successfully. Click on Close to close this dialog box. Then we will see the main installation center. We can close it. Now you will have to restart the machine.

 

Installing Northwind database in Microsoft SQL Server 2008


Now that we have finished installing Microsoft SQL Server, let us install the Northwind database.

Getting the source

Northwind database source can be downloaded from the Microsoft web site at:

http://www.microsoft.com/en-us/default.aspx

  1. Search for the Northwind database download by typing in download Northwind database as shown in the following screenshot:

  2. Click on the first result as we see in the following screenshot:

  3. Click on Download as shown in the following screenshot to start the download:

  4. After we finish downloading, we will get a file named SQL2000SampleDb.msi. Double-click on this file to begin the installation.

Installation

Following are the steps to install the Northwind database:

  1. Welcome Dialog: As shown in the following screenshot, it is simply a welcome dialog. Click on the Next button.

  2. License Agreement: Select the I Agree radio button and click on Next as shown in the following screenshot:

  3. Choose Installation Options: We will leave the default settings as we see in the following screenshot and click on Next.

  4. Confirm Installation: We can now install the Northwind database on our machine and click on Next.

  5. Installing the Database: As shown in the following screenshot, the database scripts will be installed on our local drive.

  6. Installation Complete: After the scripts have been installed, we will find a folder named SQL Server 2000 Sample Databases created in the C:\. We will use one of these files to install the Northwind database into SQL Server 2008.

  7. Open SQL Server Management Studio: From the Start menu select All Programs, then select Microsoft SQL Servers 2008, and click on SQL Server Management Studio.

  8. Connect to SQL Server 2008: As shown in the following screenshot, select Database Engine from the Server type: menu, Server name: is localhost (or "."), which represents our machine. The Authentication type is SQL Server Authentication, the same option that we selected during installation. The Login name is sa, which represents the default user of SQL Server, and the password is asd123 or the password you had entered while installing the SQL Server. After filling in all the fields, click on Connect.

  9. Create Northwind database in SQL Server 2008: Open C:\SQL Server 2000 Sample Databases. This is where the database scripts are installed. Drag the filenamedinstnwnd.sql file, which contains all SQL scripts required to create the Northwind database on our server, and drop it in SQL Server Management Studio. As we can see in the following screenshot, click on the Execute button to run the scripts.

  10. After all scripts are executed correctly, we will see Northwind in our databases, as can be seen in the following screenshot:

 

Summary


In this chapter, we learned how to set up all the tools we will need to complete our sample application. In the next chapter, we will start with the design of our application and we will see that this application contains most types of Crystal Reports.

About the Author

  • Mahmoud Elkoush

    Mahmoud Elkoush has over six years experience in software development. He has used many technologies throughout his career such as Microsoft Visual Studio, Microsoft SQL Server, Oracle database, Crystal Reports, and so on. He has worked as a Project Manager in the Kingdom of Saudi Arabia for nearly two years, and currently works as the Chief Information Officer of Geomeric. This is the first book that Mahmoud has written, and he hopes it will be the first of many.

    Browse publications by this author
Book Title
Access this book, plus 7,500 other titles for FREE
Access now