You are on page 1of 13

Configuring your Web.

Config file Visual Studio 2008

A Web.Config file in an ASP.NET web application stores global settings such as database connection information, assembly references, and error handling. This file is written in XML, and its root element must always be <configuration>. This is an advanced configuration and is not required.

The following elements are unique to Crystal Reports and may be added to your Web.Config file. Note Note

Version numbers may change according to the product that you have.

CrystalImageHandler

The CrystalImageHandler element displays all dynamic images in the CrystalReportViewer control. This setting configures the ASP.NET worker process to redirect requests made to CrystalImageHandler.aspx to an internal only image handler class. If you do not have the CrystalImageHandler setting in your Web.Config file, the images on your website will not show. This element is automatically added to the Web.Config file when you add the CrystalReportViewer control to your website.

<system.web> <httpHandlers> <add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/> </httpHandlers> </system.web>

CrystalImageCleaner

The CrystalImageCleaner process automatically deletes dynamically generated images rendered by the CrystalReportViewer control. This setting allows you to set the interval of time between scans of the image directory and the minimum age of the files before they are deleted. This

element is automatically added to the Web.Config file when you add the CrystalReportViewer control to your website. This corresponds to the CrystalImageCleaner class.

CrystalImageCleaner-Sleep initializes the amount of time in milliseconds that the image cleaner sleeps before scanning and cleaning up image files in the dynamic image directory. CrystalImageCleaner-Age initializes the minimum age in milliseconds of a file before it is deleted. CrystalImageCleaner-AutoStart controls the CrystalImageCleaner process. The image cleaner cleans up the temporary images that are created when viewing a report whose value is set to true.

Note Note

Only one image cleaner can be started in a single ASP.NET worker process.

<appSettings> <add key="CrystalImageCleaner-AutoStart" value="true" /> <add key="CrystalImageCleaner-Sleep" value="60000" /> <add key="CrystalImageCleaner-Age" value="120000" /> </appSettings>

printControl

The printControl element allows you to print the report directly to your local printer. By default, this control is not installed on your local machine and must be downloaded separately. You can download the PrintControl .cab file from the Business Objects technical support website: http://technicalsupport.businessobjects.com/1. This setting makes the .cab file visible to your Crystal Reports.NET website. This element needs to be manually added to the Web.Config file of your website.

<configSections> <sectionGroup name="businessObjects">

<sectionGroup name="crystalReports"> <section name="printControl" type="System.Configuration.NameValueSectionHandler, System, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null" /> </sectionGroup> </sectionGroup> </configSections>

<businessObjects> <crystalReports> <printControl> <add key="url" value="http://localhost/PrintControl.cab" /> </printControl> </crystalReports> </businessObjects>

reportMappings

The reportMappings element updates websites created in Visual Studio 2003 that use embedded reports to non-embedded websites when opened in Visual Studio 2005 or later. This setting converts the .dll file created in Visual Studio 2003 to a disk file. Visual Studio 2005 and 2008 do not support embedded websites and you must modify your Web.Config file to ensure that your report is still functional with the newer version of Visual Studio. This element needs to be manually added to the Web.Config file of your website. The reportMappings setting requires an absolute path. Note Note

This element is valid for Visual Studio 2005 and Visual Studio 2008 only.

<configSections> <sectionGroup name="businessObjects"> <sectionGroup name="crystalReports">

<section name="reportMappings" type="CrystalDecisions.Shared.ReportMappingHandler, CrystalDecisions.Shared, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, Custom=null" /> </sectionGroup> </sectionGroup> </configSections>

<businessObjects> <crystalReports> <reportMappings> <add reportName="World Sales Report.rpt" path="C:\Report\World Sales Report.rpt" /> </reportMappings> </crystalReports> </businessObjects>

UseBrowserLocale

The UseBrowserLocale element retrieves the language settings in your browser for the CrystalReportViewer control. When set to true, this setting configures the CrystalReportViewer control to observe the browser locale. When set to false, this setting restricts the locale that is displayed page-bypage. This element needs to be manually added to the Web.Config file of your website.

<configSections> <sectionGroup name="businessObjects"> <sectionGroup name="crystalReports"> <section name="crystalReportViewer" type="System.Configuration.NameValueSectionHandler" /> </sectionGroup> </sectionGroup> </configSections>

<businessObjects> <crystalReportViewer> <add key="UseBrowserLocale" value="true" /> </crystalReportViewer> </businessObjects>

serverFileReportManager

The serverFileReportManager element is a web service that enumerates the server files on the server machine. This setting allows you to get a list of objects (folders and reports) from a remote machine. This setting assigns the root of the file directory for the server. In this example, the root is set to c:\inetpub\wwroot. This element needs to be manually added to the Web.Config file of your website. Note Note

This corresponds to the serverFileReportManager class.

<configSections> <sectionGroup name="crystalDecisions"> <section name="serverFileReportManager" type="System.Configuration.NameValueSectionHandler, System, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null" /> </sectionGroup> </configSections>

<crystalDecisions> <serverFileReportManager> <add key="rootDirectory" value="c:\inetpub\wwwroot" /> </serverFileReportManager> </crystalDecisions>

globalResourcePath

The globalResourcePath element is the reference to the file directory path for global resources. This file directory contains your custom language resources in a central location and can be shared across multiple web applications. This setting allows you to access the global resources in a specific website. In CrystalReports.NET, the default resource files are not shipped with the product install, but can be downloaded from the Business Objects technical support website: http://technicalsupport.businessobjects.com/1. This element needs to be manually added to the Web.Config file of your website.

<appSettings> <add key="globalResourcePath" value="c:\CrystalReportViewer_resource_files\"/> </appSettings>

Sample Web.Config File

<?xml version="1.0"?> <configuration> <appSettings> <add key="CrystalImageCleaner-AutoStart" value="true"/> <add key="CrystalImageCleaner-Sleep" value="60000"/> <add key="CrystalImageCleaner-Age" value="120000"/> </appSettings> <connectionStrings/> <system.web> <compilation debug="true"> <assemblies> <add assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.Shared, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.ReportSource, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.Enterprise.Framework, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>

<add assembly="CrystalDecisions.Enterprise.Desktop.Report, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.CrystalReports.Engine, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.Enterprise.InfoStore, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/> </assemblies> </compilation> <authentication mode="Windows"/> <httpHandlers> <add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/> </httpHandlers> </system.web> </configuration>

Configuring your Web.Config file


Visual Studio 2008 Other Versions

0 out of 13 rated this helpful Rate this topic A Web.Config file in an ASP.NET web application stores global settings such as database connection information, assembly references, and error handling. This file is written in XML, and its root element must always be <configuration>. This is an advanced configuration and is not required. The following elements are unique to Crystal Reports and may be added to your Web.Config file. Note Version numbers may change according to the product that you have. CrystalImageHandler

The CrystalImageHandler element displays all dynamic images in the CrystalReportViewer control. This setting configures the ASP.NET worker process to redirect requests made to CrystalImageHandler.aspx to an internal only image handler class. If you do not have the CrystalImageHandler setting in your Web.Config file, the images on your website will not show. This element is automatically added to the Web.Config file when you add the CrystalReportViewer control to your website.
<system.web> <httpHandlers> <add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/> </httpHandlers> </system.web>

CrystalImageCleaner The CrystalImageCleaner process automatically deletes dynamically generated images rendered by the CrystalReportViewer control. This setting allows you to set the interval of time between scans of the image directory and the minimum age of the files before they are deleted. This element is automatically added to the Web.Config file when you add the CrystalReportViewer control to your website. This corresponds to the CrystalImageCleaner class.

CrystalImageCleaner-Sleep initializes the amount of time in milliseconds that the image cleaner sleeps before scanning and cleaning up image files in the dynamic image directory. CrystalImageCleaner-Age initializes the minimum age in milliseconds of a file before it is deleted. CrystalImageCleaner-AutoStart controls the CrystalImageCleaner process. The image cleaner cleans up the temporary images that are created when viewing a report whose value is set to true.

Note Only one image cleaner can be started in a single ASP.NET worker process.
<appSettings> <add key="CrystalImageCleaner-AutoStart" value="true" /> <add key="CrystalImageCleaner-Sleep" value="60000" /> <add key="CrystalImageCleaner-Age" value="120000" /> </appSettings>

printControl The printControl element allows you to print the report directly to your local printer. By default, this control is not installed on your local machine and must be downloaded separately. You can download the PrintControl .cab file from the Business Objects technical support website: http://technicalsupport.businessobjects.com/. This setting makes the .cab file visible to your Crystal Reports.NET website. This element needs to be manually added to the Web.Config file of your website.
<configSections> <sectionGroup name="businessObjects"> <sectionGroup name="crystalReports"> <section name="printControl" type="System.Configuration.NameValueSectionHandler, System, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null" />

</sectionGroup> </sectionGroup> </configSections> <businessObjects> <crystalReports> <printControl> <add key="url" value="http://localhost/PrintControl.cab" /> </printControl> </crystalReports> </businessObjects>

reportMappings The reportMappings element updates websites created in Visual Studio 2003 that use embedded reports to non-embedded websites when opened in Visual Studio 2005 or later. This setting converts the .dll file created in Visual Studio 2003 to a disk file. Visual Studio 2005 and 2008 do not support embedded websites and you must modify your Web.Config file to ensure that your report is still functional with the newer version of Visual Studio. This element needs to be manually added to the Web.Config file of your website. The reportMappings setting requires an absolute path. Note This element is valid for Visual Studio 2005 and Visual Studio 2008 only.
<configSections> <sectionGroup name="businessObjects"> <sectionGroup name="crystalReports"> <section name="reportMappings" type="CrystalDecisions.Shared.ReportMappingHandler, CrystalDecisions.Shared, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, Custom=null" /> </sectionGroup> </sectionGroup> </configSections> <businessObjects> <crystalReports> <reportMappings> <add reportName="World Sales Report.rpt" path="C:\Report\World Sales Report.rpt" /> </reportMappings> </crystalReports> </businessObjects>

UseBrowserLocale The UseBrowserLocale element retrieves the language settings in your browser for the CrystalReportViewer control. When set to true, this setting configures the CrystalReportViewer control to observe the browser locale. When set to false, this setting restricts the locale that is displayed page-by-page. This element needs to be manually added to the Web.Config file of your website.
<configSections> <sectionGroup name="businessObjects"> <sectionGroup name="crystalReports"> <section name="crystalReportViewer" type="System.Configuration.NameValueSectionHandler" /> </sectionGroup> </sectionGroup>

</configSections> <businessObjects> <crystalReportViewer> <add key="UseBrowserLocale" value="true" /> </crystalReportViewer> </businessObjects>

serverFileReportManager The serverFileReportManager element is a web service that enumerates the server files on the server machine. This setting allows you to get a list of objects (folders and reports) from a remote machine. This setting assigns the root of the file directory for the server. In this example, the root is set to c:\inetpub\wwroot. This element needs to be manually added to the Web.Config file of your website. Note This corresponds to the serverFileReportManager class.
<configSections> <sectionGroup name="crystalDecisions"> <section name="serverFileReportManager" type="System.Configuration.NameValueSectionHandler, System, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null" /> </sectionGroup> </configSections> <crystalDecisions> <serverFileReportManager> <add key="rootDirectory" value="c:\inetpub\wwwroot" /> </serverFileReportManager> </crystalDecisions>

globalResourcePath The globalResourcePath element is the reference to the file directory path for global resources. This file directory contains your custom language resources in a central location and can be shared across multiple web applications. This setting allows you to access the global resources in a specific website. In CrystalReports.NET, the default resource files are not shipped with the product install, but can be downloaded from the Business Objects technical support website: http://technicalsupport.businessobjects.com/. This element needs to be manually added to the Web.Config file of your website.
<appSettings> <add key="globalResourcePath" value="c:\CrystalReportViewer_resource_files\"/> </appSettings>

Sample Web.Config File


<?xml version="1.0"?> <configuration> <appSettings> <add key="CrystalImageCleaner-AutoStart" value="true"/> <add key="CrystalImageCleaner-Sleep" value="60000"/> <add key="CrystalImageCleaner-Age" value="120000"/> </appSettings> <connectionStrings/>

<system.web> <compilation debug="true"> <assemblies> <add assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.Shared, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.ReportSource, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.Enterprise.Framework, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.Enterprise.Desktop.Report, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.CrystalReports.Engine, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.Enterprise.InfoStore, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/> <add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/> </assemblies> </compilation> <authentication mode="Windows"/> <httpHandlers> <add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/> </httpHandlers> </system.web> </configuration>

Printing
4 out of 11 rated this helpful Rate this topic Visual Studio 2005 You can print a report two ways with Crystal Reports for Visual Studio 2005:

From the GUI, with the Print button on the toolbar that is provided with the CrystalReportViewer control on a Web or Windows Form. From the SDK, with the ReportDocument object.

Printing from the GUI In a Windows application, the print button on the CrystalReportViewer control toolbar opens the standard print dialog box. In a Web application the print button on the CrystalReportViewer control toolbar opens a secondary Web page that emulates a print dialog box. A pdf is generated on the Web server, and then downloaded and displayed on the Web page. (It works much like Print Preview.) Printing from the SDK Users typically print reports from their own machines, with the print button in the toolbar of the CrystalReportViewer control. However, if you design a Web application in which reports are

printed on the Web server, you could write code with the ReportDocument object model to print reports directly from the server to a specific printer. Printing using the ActiveX control In recent versions of Crystal Reports, you can specify the print mode using the new CrystalReportViewer.PrintMode property. It contains two enumerated types: ActiveX, and PDF.

When the property is set to PrintMode.PDF, the report is exported as a PDF on the Web server, and then streamed to the browser. The user is given the option to print directly to the printer. This option is cross-platform compatible. When the property is set to PrintMode.ActiveX, an ActiveX printing control allows users to print the report directly to their local printer. Note In Crystal Reports for Visual Studio 2005, the ActiveX print control is not installed on the local machine, in order to meet Microsoft security requirements. Instead, it must be accessed as a .cab file from an external URL. The PrintControl.cab file can be downloaded from the Business Objects tech support Web Site, at which point you can place the cab file in a web server virtual directory for URL access. To make the cab file visible to your Crystal Reports for Visual Studio 2005 Web Site, add the following xml to your Web Site's web.config file:
<configSections> <sectionGroup name="businessObjects"> <sectionGroup name="crystalReports"> <section name="printControl" type="System.Configuration.NameValueSectionHandler, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null" /> </sectionGroup> </sectionGroup> </configSections> <businessObjects> <crystalReports> <printControl> <add key="url" value="http://myserver/PrintControl.cab" /> </printControl> </crystalReports> </businessObjects>

Note Only Internet Explorer supports ActiveX controls. Printing from a nonInternet Explorer client (FireFox, Safari, Mozilla, and others) reverts to the PDF export dialog.

UPDATE: Here is a minimum working sample for integrated authentication with SQL Server. You should use the ConnectionProperties of the table object to set connection parameters.
Dim Dim Dim Dim app As New CRAXDDRT.Application rpt As CRAXDDRT.Report tbl As CRAXDDRT.DatabaseTable tbls As CRAXDDRT.DatabaseTables

Set rpt = app.OpenReport("C:\report\repotest.rpt")

For Each tbl In rpt.Database.Tables tbl.ConnectionProperties.DeleteAll tbl.ConnectionProperties.Add "Provider", "SQLOLEDB" tbl.ConnectionProperties.Add "Data Source", "localhost" tbl.ConnectionProperties.Add "Initial Catalog", "testdb" tbl.ConnectionProperties.Add "Integrated Security", "True" ' cut for sql authentication 'tbl.ConnectionProperties.Add "User Id", "myuser" ' add for sql authentication 'tbl.ConnectionProperties.Add "Password", "mypass" ' add for sql authentication Next tbl 'This removes the schema from the Database Table's Location property. Set tbls = rpt.Database.Tables For Each tbl In tbls With tbl .Location = .Name End With Next 'View the report Viewer.ReportSource = rpt Viewer.ViewReport

You might also like