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.
![](https://media.barcodewiz.com/images/171b0f95-e500-4225-a1d8-c6dc633003d8-C128-RDLC-THUMB.png)
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](https://media.barcodewiz.com/images/2a841ea8-4ced-43fe-9866-275aa016b7ad-RDLC-001.png)
- 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](https://media.barcodewiz.com/images/99681afb-7ae6-4622-8894-e51c97cdc209-RDLC-002.png)
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](https://media.barcodewiz.com/images/dbb4b22d-a906-4077-bdc7-ec4048e2eae6-RDLC-003.png)
- Name your project
- Select the Framework that you plan to use
- Click on Create
![Configure new project](https://media.barcodewiz.com/images/3c45db0d-d99b-4440-8c96-d167eb0b9869-C128-RDLC-001.png)
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](https://media.barcodewiz.com/images/e81dc330-939a-466d-95bf-721065e28381-RDLC-004.png)
- Select Dataset for the database model and click Next
![Choosing a Database Model for RDLC Project in Visual Studio](https://media.barcodewiz.com/images/3f1f32a5-39f1-42ca-912b-717fdb426dda-RDLC-005.png)
- Click on New Connection...
![Choosing a database Connection type with RDLC Visual Studio Project](https://media.barcodewiz.com/images/f2a67d42-a4eb-478e-b9bc-d426e722820c-RDLC-006.png)
- 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](https://media.barcodewiz.com/images/0c1817a5-098f-4b07-85db-534cc05f338c-RDLC-007.png)
- On the Add Connection screen click on Browse...
![Setting up a database connection to use with RDLC Report](https://media.barcodewiz.com/images/1129d6dc-79ff-43ce-97c9-bfdd7ba14e0c-RDLC-008.png)
- 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](https://media.barcodewiz.com/images/18e0b890-7580-4ea6-a82e-574c864d963b-C128-RDLC-002.png)
- 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](https://media.barcodewiz.com/images/5774d7e5-1489-45c0-b8dc-bbec0d63a87c-C128-RDLC-003.png)
- 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](https://media.barcodewiz.com/images/db5f7f19-b219-46f8-b1f5-dea854a2d7a2-C128-RDLC-004.png)
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](https://media.barcodewiz.com/images/ad85ab9e-a5a1-497f-b61c-13ba2ca46fd4-C128-RDLC-005.png)
- 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](https://media.barcodewiz.com/images/d7e10284-ae00-4786-b79b-62fd93d8e616-C128-RDLC-006.png)
- Click on Choose Data Sources
![Click on Choose Data Sources](https://media.barcodewiz.com/images/70e8df56-2476-4259-90d0-14fbcba06b32-C128-RDLC-007.png)
- Expand available sources and select the one you configured earlier.
- In our case - Items
![Expand available sources and select - Items](https://media.barcodewiz.com/images/168e0161-7372-4249-b070-82fd82111d4d-C128-RDLC-008.png)
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](https://media.barcodewiz.com/images/a9872d68-f55d-4035-be37-9f3ba5fd9b88-RDLC-009.png)
- Go to Configuration Manager...
![Altering configuration of the processor platform](https://media.barcodewiz.com/images/52697027-cc39-4631-a7f0-e1cd45df383e-RDLC-010.png)
- (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](https://media.barcodewiz.com/images/ff864363-6121-4c91-b97a-8b9436c01609-C128-RDLC-009.png)
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...](https://media.barcodewiz.com/images/056d6ac0-e8af-4880-aad5-2da80aefd254-C128-RDLC-012.png)
- In Reference Manager click on Browse.
![Click on Browse to select references](https://media.barcodewiz.com/images/56826298-9668-42ec-83de-6d04636c4b67-RDLC-012.png)
- 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](https://media.barcodewiz.com/images/e3b6bccc-1ba1-4fb8-ad59-2c78e6926e2d-C128-RDLC-013.png)
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](https://media.barcodewiz.com/images/6e936dce-3aed-4a14-b3e3-6ec7183fb2f4-C128-RDLC-015.png)
- 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](https://media.barcodewiz.com/images/743147fb-4a8a-4b37-aaaf-56605c17f1c8-C128-RDLC-010.png)
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](https://media.barcodewiz.com/images/35d52275-20ea-4932-97f2-883ca35d620e-C128-RDLC-011.png)
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](https://media.barcodewiz.com/images/73e0160a-3258-449b-9bbb-533291ab5bf5-RDLC-013.png)
- Edit the Expression:
- =Code.MyCode128.Code128B(Fields!item_name.Value)
- Click OK
![Edit the expression - enter: =Code.MyCode128.Code128B(Fields!item_name.Value)](https://media.barcodewiz.com/images/4e9aa51e-e074-4cbb-934f-5be10f1c57c2-C128-RDLC-016.png)
- 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](https://media.barcodewiz.com/images/53bd57a7-36dd-412e-b235-3a645626ccac-C128-RDLC-017.png)
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](https://media.barcodewiz.com/images/35e4f663-7ef1-4cdd-963a-1c06b4aa6f6b-C128-RDLC-018.png)
The Report is ready!
- Click Start Without Debugging or press CTRL + F5 to preview it
![Final report](https://media.barcodewiz.com/images/4261e6e9-de4d-490e-b6ae-2a06c08f89f7-C128-RDLC-019.png)