Home  >  Barcode SDK for Local Reports  >  How to Generate Barcodes in RDLC Reports
Tutorial for Barcode Generation in Local Reports (RDLC)
In this article, you will learn how to generate barcode images in a RDLC report by using our .NET barcode library.
The following requirements are necessary for our tutorial of generating barcodes in a new client report definition (.rdlc) file, a local report.
  1. Start Visual Studio 2005 and create a new Windows Forms project through clicking File > New > Windows Application. Name the project KD Sample RDLC Reports

  2. Add new DataSet item to the Windows Forms project and name it AdventureWorks.xsd

  3. Drag TableAdapter from the toolbox to above AdventureWorks.xsd. Then TableAdapter Configuration Wizard will appear right now.

  4. Select New Connection and create a connection to the AdventureWorks SQL Server Database sample and go to next step

  5. When it comes to Enter a SQL Statement, copy following SQL statements to the textbox: SELECT ProductID, Name FROM Production.vProductAndDescription WHERE (CultureID = N'en'). Then click Finish

  6. Create a new custom Column to the DataTable through Add > Column and name the Column as KD Barcode

  7. Now we need to set the data type of the new Column KD Barcode as System.Byte[],Array of Byte. In the properties window. You may need to type the System.Byte[] manually if it is not listed in the dropdown list.

  8. Switch to forms1.cs, Add a new Repor item to the Windows application, and name the report item KDRdlcReport.rdlc

  9. In the Toolbar, drag a Table to the report from Report Item section

  10. Add three columns in AdventureWorks.xsd to the report table details section, that is, ProductID, Name and KD Barcode

  11. Drag an "Image" item to the last column KD Barcode

  12. Click that image and change its image properties:
    • Customize image item property "MIMEType" as "image/jpeg"
    • Customize image item property "Source" as "Database"
    • Customize image item property "Value" as "=Fields!KD_Barcode.Value"
  13. Swich to Forms1.cs, drag and drop a ReportViewer control to the Windows Forms

  14. Choose your created report "KDRdlcReport.rdlc" and bind data collection

  15. Switch to "Solution Explorer" and add "KeepDynamic.Barcode.RdlcReport.dll" to your project reference

  16. Copy the following C# code into the method Form1_Load, and then run the project

private void Form1_Load(object sender, EventArgs e)
        {
            // load data to the data table
            this.vProductAndDescriptionTableAdapter.Fill(this.AdventureWorks.vProductAndDescription);

            // generate a linear barcode object
            BarCode barcode = new BarCode();

            // Adjust barcode type to Code 128
            barcode.SymbologyType = SymbologyType.Code128;

            // draw barcodes for each data row
            foreach (AdventureWorks.vProductAndDescriptionRow row
            in this.AdventureWorks.vProductAndDescription.Rows)
            {
                // set barcode encoding data value
                barcode.CodeText = row.ProductID.ToString();

                // Output barcode image in Jpeg image file
                barcode.Format = System.Drawing.Imaging.ImageFormat.Jpeg;

                row.Barcode = barcode.drawBarcodeAsBytes();
            }

            this.reportViewer1.RefreshReport();
        }
Generate 1D/2D Barcodes in Local Reports Using RDLC Barcode Generator SDK
Barcode Generator SDK for RDLC reports is compatible with most common barcode symbology standards and supports more than seventy linear and two-dimensional barcode generation in local reports, such as: