Display Barcodes on Dataset Based Reports

Skip to end of metadata
Go to start of metadata
Purpose of this article is to show you how easy it is to display barcodes in your dataset based reports with the help of our Barcode control.

In this article, we will cover:

  • Create new report
  • Add and configure dataset
  • Add the Barcode control to the report
  • Use a field of the dataset as codetext, for generating barcode
  • Set barcode symbology
  • View the final report after deploying to the SQL Server Reporting Services

Using datasets in reports is very common when programming with SQL Server Reporting Services. We provide a SQL query to populate the records in a dataset and use it as the data source for the report. Columns are bound to the fields in the dataset to automatically display the correct value of the record.

In this article, we will use a simple table with 3 columns for our report. Below are the details of the table:

Table Name: Product

Column Name Purpose
ID Auto number. Used as primary key
ProductName Store the name of product
ProductSerial Store the serial number. Display barcode for this value


Our report will contain 4 columns. 3 columns will display the values from the table. The 4th column will contain the barcode control, which will use the value of “ProductSerial” column as codetext, for each of the rows.

Create a New Report

First open the Visual Studio, create a new “Report Server” project and add a new report. Choose the “Report Wizard” for creating the report. First step is to choose the data source as shown in the figure below.


Click on the “Edit” button for creating the connection string. Choose the database server and database as shown in the below figure.


Make sure that the connection string is valid by pressing the “Test Connection” button, which should say that “test connection succeeded”.
Press OK to go to the next screen.


Select all the columns from the Product table. Make sure that the query is valid by executing it in the query designer window; it should show some records from the table.
Choose the “Tabular” option in the report type screen.
Press “Next” and add all the fields in the “Detail” category.


Press “Next” and name the report as “Products List” and press “Finish” to create the report.
The report should now be created and it will show all the 3 columns from the “Product” table. Below is the preview of the report, as shown in the “preview” tab in Visual Studio.

Add Barcode column

For displaying the barcode, we need to add a new column. Open the report in “design” view, right click on the “Product Serial” column and choose “Insert column” | “Right”. A new column will be added. Name this column as “Barcode”.
Open the toolbox in Visual Studio and drag the Aspose.BarCode for Reporting Services control to the newly created column. Your report should now look like below:

Set the Barcode Control to use the value “ProductSerial” column as Codetext

We now need to set the codetext and symbology type in the barcode control.

Set Symbology

Right click on the barcode control and choose “properties” from the context menu. It will open the barcode designer window. Choose the desired barcode symbology from the drop down list. In this example, we will choose the “Datamatrix” symbology, as shown in the below figure:

Set Codetext

As you can see the code text has a default value of “12345678”. We need to change it to set the product serial number to be used as codetext. Press the fx (Expression) button next to the “code text”. It will open the “Expression” window.
Select “Fields” from the “Catego r y” and select the “ProductSerial” from the “Values” list. It should display “ =Fields!ProductSerial.Value ” in the expression text box.


Press “OK”. This will now set the value of “ProductSerial” column of the dataset as the codetext of barcode. The “preview” of the report should now look like as the below figure:


You can see that the barcode control is picking the corresponding serial number for each product as its codetext.

Deploy the Report

You can also test by deploying the report to the SQL Server Reporting Services. Below is the screenshot of the report when opened in Internet Explorer after deploying it to the SSRS.

Summary
The barcode control for Reporting Services provides the custom properties window for designing the barcode. It also provides a way to give any expression (fx) for the codetext value. It can be a constant string or value of a dataset column. This article was about specifying the serial number column of a table as the codetext, which was very easily done using the barcode control.
Reference URLs
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.