How to use Barcode in Reporting Services 2005 report's Code section - Product List Sa
- Neodynamic Barcode Professional 3.0 for Reporting Services or greater
- Microsoft .NET Framework 2.0 or greater
- Microsoft Visual Studio 2005 or SQL Server Business Intelligence Development Studio
- Microsoft SQL Server 2005 Express, Workgroup, Standard or Enterprise Edition
- Microsoft SQL Server 2005 Reporting Services
In the following walkthrough we'll create a Report Server Project which features barcode images by using Barcode Professional, Visual Studio 2005 or SQL Server Business Intelligence Development Studio, and Reporting Services 2005.
In this sample we'll create a Product List RDL report by using Microsoft's AdventureWorks database sample.
Follow these steps:
1. Open Visual Studio 2005 or SQL Server Business Intelligence Development Studio and create a new Report Server Project
2. Add a new Data Source pointing to the AventureWorks database
3. Add a new Report item, name it to ProductList.rdlc, and enter the following SQL Statement:
SELECT ProductID, Name, ProductModel, CultureID FROM Production.vProductAndDescription WHERE (CultureID = N'en')
5. In this sample we'll use the Code 39 Barcode Symbology, but remember that you can use ANY Barcode Symbology built-in Barcode Professional.
Follow these steps:
5.1. Ensure to install Barcode Professional for Reporting Services.
5.2. In Visual Studio and with the report opened at design-time, add a reference to the Barcode Professional assembly (Neodynamic.ReportingServices.Barcode.dll) going to Report > Report properties... Add the reference as is shown in the following figure:
Notice that the assembly version could be different from the image depending on the Barcode Professional for Reporting Services version installed on your machine.
We'll need to create an instance of Barcode Professional to use it then in a custom function on the Report's Code section. To do this, add a new entry in the Classes grid as is shown in the following figure. Notice that the instance will be named objBarcode and that the full reference to the class is Neodynamic.ReportingServices.Barcode
5.3. Finally, we need to create a VB.NET function which will be invoked to get the appropriate Code 39 barcode image by using the Barcode Professional instance created in the previous step. In the Code tab write the following code:
Public Function GetBarcode(ByVal code As String) As Byte()
'Set the value to encode
objBarcode.Code = code
'Set the Code 39 Barcode Symbology
objBarcode.Symbology = _
Set the Bar's height to 0.25 in
objBarcode.BarHeight = 0.25F
objBarcode.AddChecksum = False
objBarcode.AutoSize = True
'Generate the barcode image
This VB.NET function called GetBarcode requires a code parameter. This value will be specified with some fields of the DataSet in the Data Source report. And as you can see in this function you can set any property of Barcode Professional.