Data Matrix Barcodes in RDLC Reports
Generating Reports with Data Matrix 2D Barcodes in Visual Studio
- This tutorial shows how you can add Data Matrix barcodes to Visual Studio RDLC Reports.
- Watch the video or follow the steps below.
![](https://media.barcodewiz.com/images/b88f2e6b-9d55-4b63-8731-2564b9b42985-DM-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.
![](https://media.barcodewiz.com/images/757bc845-78d2-46c8-89bd-61b50e4af7f2-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
![](https://media.barcodewiz.com/images/3ace437c-0717-4141-b0a1-1ed44b3313f2-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)
![](https://media.barcodewiz.com/images/a122b106-a6f3-418d-a75a-223d0391fac6-RDLC-003.png)
- Name your project
- Select the Framework that you plan to use
- Click on Create
![](https://media.barcodewiz.com/images/7ead2321-366c-4bb8-a361-acd87964e8f9-DM-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
![](https://media.barcodewiz.com/images/90ae7ede-8f13-47c1-920e-c365017f1c90-RDLC-004.png)
- Select Dataset for the database model and click Next
![](https://media.barcodewiz.com/images/3426f715-4bcb-4880-811c-d0e0542d26b4-RDLC-005.png)
- Click on New Connection...
![](https://media.barcodewiz.com/images/de0ec501-1d30-4297-b8c0-0e4513032c3d-RDLC-006.png)
- On the Choose Data Source screen, select Microsoft Access Database File and click on Continue
![](https://media.barcodewiz.com/images/dc86e32a-3189-40f6-b604-ce86b9b92477-RDLC-007.png)
- On the Add Connection screen click on Browse...
![](https://media.barcodewiz.com/images/8fb25983-0afa-4129-b4d0-b74480164d9b-RDLC-008.png)
- On the Select Microsoft Access Database File screen, browse to the folder Documents\BarCodeWiz Examples\BarCodeWiz Data Matrix Fonts\Access and select DataMatrix_Access_Example.mdb
- Click on Open
- On the Add Connection screen, click OK
![](https://media.barcodewiz.com/images/12c320da-7141-4848-a890-db33eb13af71-DM-RDLC-002.png)
- Select Tables to use in the Report
- click on Finish
- Click on Next on the next screen (Dataset Properties)
![](https://media.barcodewiz.com/images/50f4ffd2-1d42-453b-9907-8c3f2664e000-DM-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.
![](https://media.barcodewiz.com/images/cb631460-2f3a-42f3-b7e2-29f1c42ab462-DM-RDLC-004.png)
Step 3. Setting up the Source of the Report's Definition
- Double - click Form1.cs in Solution Explorer
![](https://media.barcodewiz.com/images/004aa76c-e62a-4a4d-9466-ccd9797883b3-DM-RDLC-005.png)
- Configure Data Sources:
- Bind your Report with Form1
- Click on the tiny triangle just below the Close button
- Select MyDataMatrixReport.report1.rdlc
![](https://media.barcodewiz.com/images/451bb1c8-f96f-463c-89af-f5efd7551c7c-DM-RDLC-006.png)
- Click on Choose Data Sources
![](https://media.barcodewiz.com/images/c4643fe2-1b47-4b37-8608-de468aca2094-DM-RDLC-007.png)
- Expand available sources and select the one you configured earlier.
- In our case - Items
![](https://media.barcodewiz.com/images/a5c87280-963c-4f64-ab15-cfe6e7e62221-DM-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.
![](https://media.barcodewiz.com/images/b4c06a22-4ad2-43a1-9cd4-8edceadf884e-RDLC-009.png)
- Go to Configuration Manager...
![](https://media.barcodewiz.com/images/ed699ecc-20e2-4e32-8dde-79090de8b820-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
![](https://media.barcodewiz.com/images/97472f9b-a16c-4ee5-92b8-6cb966610ead-RDLC-011.png)
Step 5. Configure Report Properties
- Right-click on the empty area of Report1.rdlc and select Report Properties
![](https://media.barcodewiz.com/images/c680be3a-fd39-48df-ab26-d2813a849023-DM-RDLC-009.png)
- In the Report Properties window, select the References section.
- 1) Click Add to add the assembly
- 2) Type: BarCodeWizFonts.DataMatrix
- 3) Click Add to add a class instance
- 4) Type BarCodeWizFonts.DataMatrix.DataMatrixFonts for class name and MyDataMatrix for instance name.
![](https://media.barcodewiz.com/images/172414b9-0427-4d54-8772-2b7fc8f05274-DM-RDLC-010.png)
Step 6. 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).
![](https://media.barcodewiz.com/images/ec297e85-44b0-4661-a1f5-e516bf9699bf-DM-RDLC-011.png)
Step 7. Edit the Expression
- Right-click on the column with the data to encode (item_name) and select Expression
![](https://media.barcodewiz.com/images/5db85216-b51f-42bb-8d90-364ea2206396-RDLC-013.png)
- Edit the Expression:
- =Code.MyDataMatrix.Encode( strBarcode:= Fields!item_name.Value,
symbolSize:=1, borderWidth:=1, quietZoneWidth:=5 ) - Click OK
![](https://media.barcodewiz.com/images/91409554-6525-4567-b391-90e4862c4d66-DM-RDLC-017.png)
Step 8. Add reference to BarCodeWizFonts.DataMatrix.dll
- In Solution Explorer right-click on References
- Select Add Reference...
![](https://media.barcodewiz.com/images/446b5c03-d12f-4e0c-bded-b21d10bc36e4-DM-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 Data Matrix Fonts\DotNet\net20 and add the file BarCodeWizFonts.DataMatrix.dll
- Click OK in the Reference Manager window.
![](https://media.barcodewiz.com/images/69a1f50c-5837-4c4d-8b82-1251df6612e8-DM-RDLC-013.png)
- Test your Report
- Click Start Without Debugging or press CTRL + F5
- You should see a report similar to the screenshot
![](https://media.barcodewiz.com/images/df8b6c42-7eaa-4976-88fe-6934fa03cbfa-DM-RDLC-014.png)
Step 9. Set the font
- Change the font to BCW_DM
- Set point size to 6
![](https://media.barcodewiz.com/images/3f55fefa-1e52-4a75-8fa9-d78b7cfc569e-DM-RDLC-015.png)
The Report is ready!
- Click Start Without Debugging or press CTRL + F5 to preview it
![](https://media.barcodewiz.com/images/89bb32f1-097d-45a3-b316-18ec5840872c-DM-RDLC-016.png)