This walkthrough explains the steps involved in connecting a to a CSV data source. The walkthrough is split up into the following activities:
- Adding an ActiveReport to a Visual Studio project
- Connecting the report to a CSV data source
- Adding controls to the report to contain data
- Viewing the report
Note:
- This walkthrough uses the Products_header_tab.csv sample database. By default, the Products_header_tab.csv file is located at [User Documents folder]\GrapeCity Samples\ActiveReports 11\Data\.
- Although this walkthrough uses Page reports, you can also implement this using RDL reports.
When you complete this walkthrough you get a layout that looks similar to the following at design time and at run time.
Design-Time Layout
Run-Time Layout
To add an ActiveReport to the Visual Studio project
- Create a new Visual Studio project.
- In the New Project dialog that appears, select ActiveReports 11 Page Report Application and in the Name field, rename the file as ProductsStock.
- Click OK to create a new ActiveReports 11 Page Report Application. By default a Page report is added to the project.
See Adding an ActiveReport to a Project for information on adding different report layouts.
To connect the report to a CSV data source
- In the Report Explorer, right-click the Data Sources node and select the Add Data Source option or select Data Source from the Add button.
- In the Report Data Source dialog that appears, select the General page and enter the name of the data source. By default, the data source name is set to DataSource1. This name appears as a child node to the Data Sources node in the Report Explorer.
- Under the Type field, select CSV Provider.
- In the Connection String tab, click the Build icon to open the Configure CSV Data Source wizard.
- To specify the File Path, click the Open button and navigate to [User Documents folder]\GrapeCity Samples\ActiveReports 11\Data and select the Products_header_tab.csv file.
- Select the Column Separator as Tab from the drop-down menu. See the Sample CSV Connection String in the topic CSV Provider for further details.
- Click OK to save the changes and close the Configure CSV Data Source wizard. The Connection String tab displays the generated connection string as shown below:
Path=C:\\[User Documents folder]\\GrapeCity Samples\\ActiveReports 11\\Data
\\Products_header_tab.csv;Locale=en-US;
TextQualifier=";ColumnsSeparator= ;RowsSeparator=\r\n;HasHeaders=True
You can validate the connection string by clicking the Validate DataSource icon.
- Click OK to close the Report Data Source dialog. You have successfully connected the report to the CSV data source.
Note: The dataset for a CSV data source is automatically added. The default name of the data set is Dataset1.
To add controls to the report
- From the toolbox, drag a Table data region onto the design surface of the report.
- Select the last column of the table, right-click, and select Insert Column to the Right option to add a fourth column.
- Go to the Properties window and set the properties for the Table data region as described in the following section:
Property Name |
Property Value |
Location |
0.375in, 0.5in |
DataSetName |
Dataset1 |
Size |
5.5in, 0.75in |
FixedSize |
5.5in, 2in |
- From the Report Explorer, drag the fields into the Table Details row as described in the following section:
Field Name |
TextBox |
ProductName |
TextBox4 |
QuantityPerUnit |
TextBox5 |
UnitPrice |
TextBox6 |
UnitsInStock |
TextBox11 |
- Select the Table Header row and set FontWeight to Bold.
- From the toolbox, drag a TextBox onto the design surface of the report, go to the Properties window to set the properties as described in the following section:
Property Name |
Property Value |
Location |
2.5in, 0in |
Size |
1.375in, 0.25in |
Value |
Products Stock |
FontSize |
12pt |
FontWeight |
Bold |
To view the report
- Click the to view the report at design time.
OR
See Also