[ Team LiB ] Recipe Dynamically Creating Crystal Reports Problem You need to define a DataTable at runtime and bind it to a Crystal Report. Solution Create a DataAdapter and use it to fill a DataTable with a subset of records | Team LiB Recipe Dynamically Creating Crystal Reports Problem You need to define a DataTable at runtime and bind it to a Crystal Report. Solution Create a DataAdapter and use it to fill a DataTable with a subset of records specified by a range of OrderlD values from the Orders table joined to Order Details records from the Northwinds sample database demonstrated in the following example . Create a new report document and set its data source to the DataTable. To display the report set the source of the report view to the report document. The C code is shown in Example 7-32. Example 7-32. File Namespaces variables and constants using System using using using using using using private crv . . . Get the user entered OrderlD range. int orderldFrom orderldTo try orderldFrom orderldTo catch Exception ex Dynamic Crystal Reports return Create a DataAdapter and fill the table. String sqlText SELECT FROM Orders JOIN Order Details Order_Details ON WHERE BETWEEN orderldFrom AND orderldTo SqlDataAdapter da new SqlDataAdapter sqlText Sql_ConnectString DataTable dt new DataTable dt Create a new ReportDocument. ReportDocument cr new ReportDocument Load the report. Project_Directory @ Chapter 07 Set the data source for the report. dt Set the report document for the report view. cr Discussion Follow these steps to use a DataTable created at runtime as the data .