Code Snippets

In Crystal Reports for Visual Studio 9.0 Beta 1, code snippets are provided when coding in Visual Basic, for both Web Sites and Windows projects. A subfolder of Crystal Reports code snippets are included within the larger set of Visual Studio 9.0 Beta 1 code snippets.

Code snippets provided with Crystal Reports

Lists the code snippets included with Crystal Reports for Visual Studio 9.0 Beta 1.

The code snippets provided with Crystal Reports enable you to do the following tasks:

  • Change the Server name and Database name.
  • Export a Crystal report to a file.
  • Export a Crystal report to a PDF file with custom export format options.
  • Print a Crystal Report.
  • Set a Discrete Parameter Value to a Crystal Report.
  • Set a Range Parameter Value to a Crystal Report.
  • Set Database Logon to a Crystal report and its subreports.

Additional code snippets may also be included.

To add a Crystal Reports code snippet to your Visual Basic Web Site or Windows project

This procedure works only with a project that has been created from Project Setup. Project Setup contains specific namespace references and code configuration that is required for this procedure, and you will be unable to complete the procedure without that configuration. Therefore, before you begin this procedure, you must first follow the steps in Project Setup.

  1. Open the Web or Windows form for a Visual Basic Web Site or Windows project.

  2. From the View menu, click Code.

  3. Right-click anywhere within the ConfigureCrystalReports() method, and then click Insert Snippet.

    Note

    You created the ConfigureCrystalReports() method in Project Setup.

  4. Double-click the Accessing Data code-snippet folder.

  5. Scroll down to the crystal reports code-snippet folder, and then double-click it.

  6. Read over the list of Crystal Reports snippets, choose one, and double-click that snippet.

    The code snippet appears within the ConfigureCrystalReports() method.

  7. Customize the code snippet for your Web Site or Windows project.