BarCodeWiz Logo

Code 128 Barcodes in RDLC Reports using Visual Studio

Generating Reports with Code 128 Barcodes in Visual Studio

  • This tutorial shows how you can add Code 128 barcodes to Visual Studio RDLC Reports.
  • Watch the video or follow the steps below.

Before You Begin...

  • Make sure you've got Microsoft RDLC Report Designer installed.
  • (1) To install it, go to Extensions Manage Extensions
  • (2) Type RDLC in the search field
  • (3) Click Download
  • Proceed with installation.
Installation of Microsoft RDLC Report Designer in Visual Studio

  • Check if you have Microsoft.SqlServer.Types installed.
  • Otherwise go to Project Manage NuGet Packages...
  • On the NuGet window search for Microsoft.SqlServer.Types
  • Click on Install and follow the installation wizard
Installation of Microsoft SQL Server Types in Visual Studio

Step 1. Create a new Project

  • In the main Visual Studio window, select Create a new Project
  • Type Reports and select Reports Application (in our case C# project)
Create a new Reports Application Project in Visual Studio

  • Name your project
  • Select the Framework that you plan to use
  • Click on Create
Configure new project

Step 2. Bind a Data Source

  • Select the Data Source Type that you would like to use in your reports (in our case it will be Access Database )
  • click on Next
Choosing a Data Source Type for Visual Studio RDLC Project

  • Select Dataset for the database model and click Next
Choosing a Database Model for RDLC Project in Visual Studio

  • Click on New Connection...
Choosing a database Connection type with RDLC Visual Studio Project

  • On the Choose Data Source screen, select Microsoft Access Database File and click on Continue
Selecting Microsoft Access Database File as a database Connection type with RDLC Visual Studio Project

  • On the Add Connection screen click on Browse...
Setting up a database connection to use with RDLC Report

  • On the Select Microsoft Access Database File screen, browse to the folder Documents\BarCodeWiz Examples\BarCodeWiz Code 128 Fonts and select Access_Example.mdb
  • Click on Open
  • On the Add Connection screen, click OK
Select Access_Example.mdb to create a connection to this database

  • Select Tables to use in the Report
  • click on Finish
  • Click on Next on the next screen (Dataset Properties)
Select the Items table to use in your project

  • Arrange fields for the report.
  • In our case, we have placed all the fields in Values section without summarizing.
  • Click on Next in the next screen (Choose the layout).
  • Click on Finish on the screen named Preview.
Arrange fields for your report

Step 3. Setting up the Source of the Report's Definition

  • Double - click Form1.cs in Solution Explorer
Double-click Form1.cs in Solution Explorer to enter its configuration

  • Configure Data Sources:
  • Bind your Report with Form1
  • Click on the tiny triangle just below the Close button
  • Select MyCode128Report.report1.rdlc
Select MyCode128Report.report1.rdlc to bind it with your report

  • Click on Choose Data Sources
Click on Choose Data Sources

  • Expand available sources and select the one you configured earlier.
  • In our case - Items
Expand available sources and select - Items

Step 4.  Changing the Project Platform to x64

  • If you Start your Project now, you would receive an error saying there is no OLEDB driver for ACCESS files on the machine. 
  • To prevent that, we have to switch the debug to x64 processors.
32-bit OLEDB provider is missing

  • Go to Configuration Manager...
Altering configuration of the processor platform

  • (1) In Configuration Manager window, select New from the list under Platform
  • (2) In New Project Platform, select x64
  • Click OK and Close
Select New, to add a new Project platform

Step 5. Add reference to BarCodeWizFonts.Code128.dll

  • In Solution Explorer right-click on References
  • Select Add Reference...
Right-click on References in Solution Explorer and select Add Reference...

  • In Reference Manager click on Browse.
Click on Browse to select references

  • In the Select the files to reference window, browse to folder Program Files\BarCodeWiz\BarCodeWiz Code 128 Fonts\DotNet\net20 and add the file BarCodeWizFonts.Code128.dll
  • Click OK in the Reference Manager window.
Select BarCodeWizFonts.Code128.dll to add it as a reference to your report's project

Step 6. Configure Report Properties

  • Right-click on the empty area of Report1.rdlc and select Report Properties
Right-click in an empty area of your report and select Reports Properties to configure them

  • In the Report Properties window, select the References section.
  • 1) Click Add to add the assembly
  • 2) Type: BarCodeWizFonts.Code128
  • 3) Click Add to add a class instance
  • 4) Type BarCodeWizFonts.Code128.Code128Fonts for class name and MyCode128 for instance name.
Configure report's properties

Step 7. Insert a new column with data to encode

  • Right-click on the last column's header and select Insert Column - Right.
  • In the new column, click in the upper-right corner and select the column with data you wish to encode (in our case - item_name)
Insert a new column with data to encode

Step 8. Edit the Expression

  • Right-click on the column with the data to encode (item_name) and select Expression
Click on Expression to edit the expression

  • Edit the Expression:
  • =Code.MyCode128.Code128B(Fields!item_name.Value)
  • Click OK
Edit the expression - enter: =Code.MyCode128.Code128B(Fields!item_name.Value)

  • Test your Report
  •  Click Start Without Debugging or press CTRL + F5
  • You should see a report similar to the screenshot
Preview the report without BarCodeWiz Code 128 Font selected

Step 9. Set the font

  • Change the font to BCW_Code128B_2
  • Set point size to 26
Select BCW_Code128B_2 as a font and set 26 as the font point size

The Report is ready!

  •  Click Start Without Debugging or press CTRL + F5 to preview it
Final report