Home: Products: Microsoft® Reporting Services Barcode for SQL Server Tutorial:

Microsoft® Reporting Services Barcode Font Tutorial

IDAutomation offers several Reporting Services Barcode Integration Options. This tutorial was created for the implementation of barcode fonts with SQL Server 2000 Reporting Services and Visual Studio 2003. When using Reporting Services 2005 or later, IDAutomation recommends using the Reporting Services Barcode CRI to create barcodes on reports.

Barcode Font List | Function List | Support | Reporting Services Barcode CRI | Integration Options Index

 Reporting Services Barcode Tutorial Overview

This solution adds barcodes to Reporting Services using IDAutomation's barcode fonts and IDAutomation's .NET Report Function Custom Assembly file. This implementation only supports linear barcode types and may not work well with web reporting. The tutorial was created for SQL Server 2000 Reporting Services and Visual Studio 2003. When using Reporting Services 2005 or later, IDAutomation recommends using the Reporting Services Barcode CRI to create barcodes on reports. When using IDAutomation's barcode fonts with Reporting Services, at least 1 Developer License should be purchased.

This custom assembly formats the data specifically for use with IDAutomation's barcode fonts, and is designed to meet the specifications of the symbology laid out by the AIM and/or ANSI standards. This barcode tutorial will show how to include the IDAutomation.com custom assemblies in a Reporting Services project. This example will show how to build a report based on the "Customers" table of the Northwind database. The report will include the database fields of CompanyName, CompanyID, and ContactName. IDAutomation will add a custom field to the report, which will be used to provide a Code 128 barcode representation of the Company ID.To sign up for monthly updates about new products or upgrades, please click here.

To use this tutorial, the following requirements must to be met:

  • Visual Studio .NET 2003 should be installed.
  • Access will be needed to a SQL Server 2000 SP 3a database. (This tutorial will make use of the Northwind database that is included with the SQL Server installation.)
  • Reporting Services must be installed.
  • The .NET barcode custom assembly, IDAutomation.com.FontReportFunctions.dll, should be downloaded.
 Microsoft® Reporting Services Barcode Tutorial
  1. Install the appropriate barcode fonts on the computer system. If there is doubt as to which font is needed, IDAutomation recommends the Code 128 Barcode Font Advantage Package; this barcode may encode both numbers and letters, and is very compact. This example uses the Code 128 barcode. IDAutomation also has a Complete TrueType Barcode Font package that includes all linear barcode fonts.
  2. Download IDAutomation's Microsoft® Reporting Services Custom Assembly. The assembly, IDAutomation.com.FontReportFunctions.dll, will be in the zip file.
    Unzip the file to an easy-to-remember location.
    Copy the custom assembly dll to the Report Designer folder. The default location of the Report Designer is C:\Program Files\Microsoft SQL Server\80\Tools\Report Designer.
    The assembly also needs to be copied to the Report Server directory so that it is available for deployment. The default location of that directory is C:\Program Files\Microsoft SQL Server\MSSQL\Reporting Services\ReportServer\bin
  3. If adding the custom assembly to an existing report, skip to Step 13.
    Create a report: Select File | New | Project from the Visual Studio .NET (VS.NET) IDE menu.
    In the New Project dialog, highlight Business Intelligence Projects in the Project Types box and Report Project Wizard in the Templates box.
    Name the sample report appropriately in the Name box. Click OK.
    Select Project Type in the Visual Studio.NET IDE menu.
  4. Select the data source. For this example, the Northwind database is used.
    Ensure that the connection string is edited to properly connect to the database. Click Next.
    Select the corresponding Data Source with the Report Wizard in Microsoft Reporting Services.
  5. Create the query string for generating the report by using the Query Builder.
    Add the Customer table to the query by right-clicking the upper pane in the query builder and selecting Add Table.
    Highlight Customers and click Add and Close.
    Drag the CustomerID, CompanyName, and ContactName fields into the query. Click OK.
    Using Query Builder in MS Reporting Services to select the corresponding tables.
  6. Click Next on the Design Query Wizard.
  7. Choose the type of report (Tabular or Matrix) to create and click Next.
  8. Leave the default values for the grouping of the report and click Next.
  9. Select the style of the table and click Next.
  10. Select the Report Server (leave the default value, this was setup during Report Services installation) and the folder for the deployment of the compiled report. Click Next.
  11. Name the report "Barcode Company ID" and click Finish. The report will now be in Layout mode. A test report may be printed out to get an idea of how the output will be displayed. The following steps will add the encoded data field to the report.
  12. Right click the last column in the table.
    Select Insert Column to the right.
    Label the column "Barcode ID" by typing directly into the column header.
    Inserting a Barcode ID column into Microsoft Reporting Services.
  13. Click on the body of the report. This will activate the Report menu in the VS .NET IDE.
    Click the Report Menu | Report Properties.
    Click the References tab. At this point IDAutomation.com.FontReportFunctions.dll will be added to the report project.
  14. Click the button containing three dots next to the Assembly column.
  15. Click the Browse button on the Add Reference dialog box.
    Navigate to the location of IDAutomation.com.FontReportFunctions.dll. Select the file and click Open.
    Click OK on the Add Reference Dialog.
  16. At this point, select the class name containing the data encoding functions. This value is pulled directly from the assembly file. Also, an instance name is required. The values for these fields may be pulled directly from the image below:
    Assembly Name for IDAutomation.com Font Report Functions.
  17. Click OK. The encoding functions are now available for use in the report. For the purposes of this example, Code128 function will be used. Complete lists of available functions are listed below. 
  18. The encoding functions are added as expressions to the appropriate field. Right click the empty area below the Barcode ID field and select Expressions.

    Please note
    : There is not a graphical means to enter these functions; the information must typed into the Expression: area of the Edit Expression dialog. The format of the expressions is:
    =Code.InstanceName.FunctionName(parameter) where Code is a global module for processing custom code requests, InstanceName is the instance of the class variable assigned in step 16, FunctionName is one of the functions listed below, and the parameter is the data that needs to barcoded.

    Enter =Code.clsIDAutomationBarcode.Code128(Fields!CustomerID.Value) in the expression field.
    MS Reporting Services Expression needed to create barcode.
  19. Click the Preview tab to ensure that the function is returning data. There should be some strange characters appended to the beginning and ending of the data from the fields - this is normal. Sometimes the data has to be formatted so much it appears to be scrambled. This is normal for Code 128 and Interleaved 2 of 5 symbologies when numbers need to be compressed within the barcode.
    Preview of formatted data being displayed in Microsoft Reporting Services.
  20. Click the layout tab and apply one of the IDAutomation Code128 barcode fonts to the field containing the expression. The report may now be previewed.
    Preview of barcode being displayed in Microsoft Reporting Services.
  21. Click Build | Deploy Solution, to deploy the solution to the Report Server.
 Barcode Function List:
For all functions below, the data input type is a single string. For all number symbologies such as POSTNET and UPC, dashes or spaces may be inputted for easier readability which will be filtered out by the function before the barcode is generated. For UPC-A, UPC-E & EAN-13, the +2 and +5 add-on barcodes may be created by appending them to the end of the string.
Function Notes
Code128(Data, ApplyTilde) This is a "Code 128 Auto" function that will automatically encode any data from ASCII 0 to ASCII 127. It will automatically switch to character set C for numbers. This symbology has many options:

UCC/EAN-128 Encoding: to encode alpha-numeric UCC/EAN128, the character set must be "0" or "AUTO" for automatic (the default setting). ASCII 202 or character Ê is recognized as the FNC1 before each AI. When a barcode begins with an AI, the required start C is included automatically. For example, the UCC number of (8100)712345(21)12WH5678 should be entered as: Ê8100712345Ê2112WH5678. In most cases, the AIs will be properly represented in the human readable text. If the parenthesis is not around the correct number for the AI, enter the following extended ASCII character as the FNC1 for the correct number of digits in the user's AI:
ASCII 212 = 2 digits  ASCII 213 = 3 digits
ASCII 214 = 4 digits  ASCII 215 = 5 digits
ASCII 216 = 6 digits  ASCII 217 = 7 digits
For example, to encode (1277)56, enter Ö127756.

Apply Tilde Options: when the symbology is Code 128, the character set is AUTO and ApplyTilde is TRUE, the following options are available:

  • Encode ASCII characters: the format ~ddd may be used to specify the ASCII code of the character to be encoded. For example, if the user enters the following text in the Data field: 128~029TEST the user will actually be encoding 128GSTEST Where GS is a delimiter ASCII 29 character. Other commonly used ASCII codes are ~032 the space, ~202 the FNC1, ~197 the FNC2, ~009 the tab and ~013 which is a return function. For encoding other functions, please refer to IDAutomation's ASCII chart.
  • Create a Mod 10 Check digit: to create a Mod 10 check digit for xx number of characters add the following to the DataToEncode: ~mnn (where nn is a 2 digit number representing the number of characters preceding the tilde in which to base the Mod 10 calculation). The additional MOD 10 check digit is commonly used in UCC or EAN barcode types. For example, setting the DataToEncode property to Ê4021234567890123456~m16 will cause a mod 10 check digit to be created based on all 16 characters before the tilde. The human readable text and scanned data will display as (402)12345678901234566. The final 6 is the mod 10 check digit and replaces ~m16.

Review the Code 128 Data Sheet and FAQ for more information on this barcode type.

Code128HumanReadable(Data, ApplyTilde) Returns the human readable text that would go underneath or above the barcode, which describes the data encoded in the barcode. The second parameter (a true or false value) determines if the tilde character (~) should be interpreted for special processing as documented here.
Code128a(Data) Use the characters from set B to print characters not on the keyboard; the scanner will scan characters from set A. Formats output to the Code 128 barcode fonts.
Code128b(Data) Returns codes formatted to the Code 128 character set B. Formats output to the Code 128 barcode fonts.
Code128c(Data) This code128 function "interleaves" numbers into pairs for high density. An even number of digits is required.
UCC128(Data) Creates a UCC128 barcode. More information about AIs and UCC/EAN-128 is located here.
I2of5() This function "interleaves" numbers into pairs for high density without check digits and formats the return string to the Interleaved 2 of 5 fonts. An even number of digits are required.
I2of5Mod10(Data, Number) (Data, 0) performs the mod10 checksum calculation for increased accuracy and formats the return string to the Interleaved 2 of 5 fonts. MOD 10 checksums are required for SSC-14 when using Interleaved 2 of 5 for that purpose. An odd number of digits is required.
(Data, 1) returns the human readable data with the MOD10 check digit included.
(Data, 2) returns the MOD10 check digit.
Code39() Formats the output to print using Code 39 fonts.
Code39Mod43(Data, Number) (Data, 0) performs the mod43 checksum calculation for increased accuracy and then formats the output to print using Code 39 fonts. The mod43 checksum is usually required for LOGMARS applications.
(Data, 1) returns the human readable data with the check digit included.
(Data, 2) returns only the check digit.
Codabar() Formats the output to print using Codabar fonts.
Postnet(Data, Number) Enter a single string of Zip, Zip + 4 or Zip + 4 + Delivery Point. The input for Data must be a number and may include dashes and spaces.
(Data, 0) formats output to the POSTNET barcode fonts.
(Data, 1) returns the human readable data with the check digit included.
(Data, 2) returns only the check digit.
MSI(Data, Number) (Data, 0) formats output to the MSI barcode fonts.
(Data, 1) returns the human readable data with the check digit included.
(Data, 2) returns only the check digit.
Code11() Only the "C" check digit is calculated which is the standard when encoding 10 digits or less.
UPCa(Data) Data is a UPC-A number string of 11, 12, 13, 14, 16 or 17 digits with or without a check digit, add-ons are supported. Formats output to the UPC/EAN barcode font. Entering incorrect data will create a barcode containing all zeros.
UPCe(Data) Data is a UPC-A number string of 11, 12, 13, 14, 16 or 17 digits with or without a check digit, add-ons are supported. The purpose of this function is to print the UPC-E barcode from a UPC-A barcode that may be compressed. It will print a UPC-A if it can not be compressed by zero suppression rules. Formats output to the UPC/EAN barcode font. Entering incorrect data will create a barcode containing "00005000000".
EAN13(Data) Data is a number string of 12, 13, 14, 15, 17 or 18 digits with or without a check digit, add-ons are supported. Formats output to the UPC/EAN barcode font. Entering incorrect data will create a barcode containing all zeros.
mod10(Data) Data is a number string. A MOD 10 check digit is returned. This is useful in calculating check digits for UCC/EAN 128 barcodes where a MOD check digit is needed.
EAN8(Data) Data is a number string of 7 or 8 characters (EAN-8 without the check digit). Formats output to the UPC/EAN barcode font. Entering incorrect data will create a barcode containing all zeros.

Using the Special Processing Features of the Tilde Character

The Code 128 function allows for the encoding of unprintable ASCII characters and calculation of a Mod 10 check character by denoting the tilde character (~) as a special processing delimiter. When the ApplyTilde parameter is set to true, the function assumes that special processing needs to happen and does not encode the tilde character. If needing to encode a tilde character in the Code 128 barcode, set the ApplyTilde property to false.

  • Encode an ASCII character: the format ~ddd may be used to specify the ASCII code of the character to be encoded. For example, if entering the following text in the Data field: 66~02977, it will actually be encoding 66GS77 where GS is a delimiter ASCII 29 character. Other commonly used ASCII codes are ~009 for a tab and ~013 which is a return function. For encoding other functions, please refer to IDAutomation's ASCII chart.
  • Create a Mod 10 Check digit: to create a Mod 10 check digit for xx number of characters, add the following to the DataToEncode: ~mnn (where nn is a 2 digit number representing the number of characters preceding the tilde in which to base the Mod 10 calculation). The additional MOD 10 check digit is commonly used in UCC or EAN barcode types. For example, setting the DataToEncode property to Ê4021234567890123456~m16 will cause a mod 10 check digit to be created based on all 16 characters before the tilde. The human readable text and scanned data will display as (402)12345678901234566. The final 6 is the mod 10 check digit and replaces ~m16.

Additional Features of the Code 128 Auto Function

  • Manual setting of the number of Application Identifier characters: In most cases, the AIs will be properly represented in the human readable text. If the parenthesis is not around the correct number for the AI, enter the following extended ASCII character as the FNC1 for the correct number of digits in the AI:
    ASCII 212 = 2 digits
    ASCII 213 = 3 digits
    ASCII 214 = 4 digits
    ASCII 215 = 5 digits
    ASCII 216 = 6 digits

    ASCII 217 = 7 digits
    For example, to encode (1277)56, enter Ö127756.
  • FNC2: When necessary, the FNC2 character may be inserted into the DataToEncode string by using ASCII 197. For example, Å8012349091. IDAutomation's SC5USB Scanner may be programmed to hold the barcode starting with the FNC2 in memory and only transmit it to the computer after scanning a barcode containing the FNC1.

To sign up for monthly updates about new products or upgrades, please click here.Related Links and Information:

 

© Copyright 2003-2008 IDAutomation.com, Inc., All Rights Reserved. Legal Notices.

 

Over 70% of Fortune 100 companies use IDAutomation's products to automate their businesses.