In this simple guide, you will learn how to use the Barcode DLL component in RDL reports.
- Visual Studio (VS) 2005/2008/2010 or Business Intelligent Development Studio (BIDS) 2005/2008/2012
- Reporting Services 2005/2008/2008-R2/2012 ANY Editions (Express, Workgroup, Web, Developer, Standard, Enterprise or Datacenter)
In the following sample you'll create a Report Server Project which features barcode images by using Barcode Professional DLL component. This project will contain a simple RDL report displaying a List of products from Microsoft's AdventureWorks database sample (http://msftdbprodsamples.codeplex.com/).
NOTE: This guide uses Visual Studio 2008 for reference but you can use the same approach if using Visual Studio 2005 or Visual Studio 2010
Please follow up these steps:
- Please ensure you correctly set up Barcode Professional DLL component (See [url]Barcode DLL Configuration[/urlhttp://www.neodynamic.com/Products/Help/BarcodeReportingServices7.0/rsconfiguration_barcode_dll.htm])
- Open VS or BIDS and create a new Report Server Project
- With the Report Server project opened, add a new Data Source pointing to the AventureWorks database sample
- 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')
- Now it's time to add a reference to Barcode DLL component and write a VB function for generating the barcode images. (see video below)
-- With the report opened at design-time, select Report > Report properties...
-- In the Report Properties dialog box, select References tab.
-- Add a reference to Neodynamic.ReportingServices.Barcode.dll which should be located under [VS Install Folder]\Common7\IDE\PrivateAssemblies
-- Finally, select Code tab. When generating barcodes, you should know about what Barcode Symbology you need to encode. Most common symbologies are Code 39, Code 128, GS1-128, GS1 DataBar, EAN-13, UPC-A, Data Matrix, QR Code, etc. The barcode symbology is set up by using Symbology property of Barcode object. In this sample, you will use Code 128 barcode, a common symbology which can be used for encoding full ASCII strings. When using Barcode DLL component, you need to write a custom VB function for generating barcodes which will be later displayed by an Image item on the report. In this sample you will create a VB function called GetBarcode which accept a parameter called valueToEncode which, in general, is a field of the report's data source. Inside this function you will create an instance of Barcode class called objBarcode setting up some properties for generating the barcode image:
Public Function GetBarcode(ByVal valueToEncode As String) As Byte()
Using objBarcode As New Neodynamic.ReportingServices.Barcode
'Set the value to encode
objBarcode.Code = valueToEncode
'Set the Code 128 Barcode Symbology
objBarcode.Symbology = _
'Set the Bar's height to 0.5 in
objBarcode.BarHeight = 0.5F
objBarcode.AutoSize = True
'Generate the barcode image
-- Close the Report Properties dialog box.
- Now, from the VS toolbox, drag & drop an Image item onto the first column of the table.
- The image item will hold the barcode image generated by the GetBarcode function. Select the image item and hit F4 to display VS Properties Window. Set up the following properties:
-- Source -> Database
-- MIMEType -> image/png
-- Sizing -> AutoSize
-- Value -> =Code.GetBarcode(Fields!ProductID.Value.ToString)
When you are ready for production, you must ensure that Barcode Professional is correctly configured and deployed to your Report Server! All steps for correctly deploying Barcode Professional DLL are stated in the Deployment topic.