Share via


Setting the DataSource

The CrystalReportSource control is similar to other DataSource controls in the DataSource framework. All of these controls implement the IDataSource and IHierarchicalDataSource interfaces, and they can be bound to other .NET controls that display data.

However, the CrystalReportSource control is different from other DataSource controls in that the CrystalReportSource control does not contain data directly. Instead, it contains a report, and the report then contains the data.

However, the CrystalReportSource control does have the ability to reset the data source for the report that it contains. It modifies the data source through a property of report: Data Sources.

Note

If the report contains sub reports, each sub report also has a DataSources property.

To access the Data Source Collection Editor dialog box

The DataSources properties are most easily set from the Data Source Collection Editor dialog box.

  1. Select the CrystalReportSource control.

  2. From Properties, expand Report.

  3. Within the Report property, click the ellipsis ( ...) on the far right of DataSources (Collection).

  4. In the Data Source Collection Editor dialog box, enter a Data Source for the main report, and any sub reports.

> [!NOTE]
> <P>For detailed instructions on configuring this dialog box, see the tutorial <A href="ms227796(v=vs.90).md">Reduced-Code Secure Database Logon in a Web Site</A>.</P>

Setting DataSources Directly in the XML

In XML, the <DataSources> tag is nested within the <CrystalReportSource> tag. Within the nested <DataSources> tag, a link to a DataSource control (for example, SqlDataSource1) is configured.

To learn how to configure the nested DataSources tag in the CrystalReportSource control, see Reduced-Code Secure Database Logon in a Web Site.

Note

Setting a data source has always been configurable in the coding model of the Crystal Reports SDK. For more information, see either Tutorial: Logging onto a Secure SQL Server Database Using SQL Authentication or Tutorial: Logging onto a Secure SQL Server Database Using Integrated Security.