Home  >  Crystal Reports Barcode Creator Control  >  Barcode Creation Guide for Crystal Reports
Crystal Reports Barcode Generator Tutorial
Crystal Reports Barcode integrates barcodes into Crystal Reports. It can create, generate linear and 2D barcodes in Crystal Reports. And it is the most affordable .NET barcode generator for barcode .NET professionals.
Crystal Reports Barcode Generator
Crystal Reports Barcode supports 70+ linear (1d) and matrix (2d) barcode standards, like:
Tutorial for Barcode Generation in Crystal Reports
This tutorial demonstrates how to add barcodes into Crystal Reports report with the .NET Barcode SDK in .NET framework application. In the tutorial, we create a dataset and insert a new field to take the barcode image. Then we will compose a few lines code in C# to process rows in the dataset and generate barcode images from the inserted field when load the Crystal Reports application.
We are going to use the barcode library to create barcode images for Crystal Reports report in Microsoft Visual Studio 2005 in the below demonstration.
  1. Start Microsoft Visual Studio 2005. Create a Crystal Reports application by choosing File>New>Project. Select the Crystal Reports Application template and change the default name as KD Sample Crystal Reports

  2. Create a "Standard" report with "Using the Report Wizard" and click "OK"

  3. In "Data" window, expand "Create New Connection" and "ADO.NET" respectively

  4. In the poped up window, locate "Demo.xsd" in your evaluation package, and then click "Finish"

  5. Then you will find an item "Table" under NewDataSet. Drag it to the Textbox of Selected Tables. Click Next

  6. Drag Table from Available Fields to Fields to Display. Then you will find two new items (Table.ID & Table.Beverages). Click Next, then select Finsh

  7. A CrystalReport1.rpt will be visible. Add a new column by clicking Field Explorer and drag KDBarcode from the Table under Database Fields to the CrystalReport1.rpt.

  8. please add "KeepDynamic.Barcode.CrystalReport.dll" to your project reference

  9. Switch to Design view, open Form1.cs, double click the form, and enter Form1.cs

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

private void Form1_Load(object sender, EventArgs e)
        {
            OleDbConnection aConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/Demo/kd/Demo.mdb" );
            aConnection.Open();
            OleDbDataAdapter dataAdapter = new OleDbDataAdapter("select * from Beverages", aConnection);
            DataSet ds = new DataSet();
            dataAdapter.Fill(ds);

            //Add a new column named "KDBarcode" to the DataSet, the new column data type is byte[]
            ds.Tables[0].Columns.Add(new DataColumn("KDBarcode", typeof(byte[])));
            BarCode barcode = new BarCode();
            barcode.SymbologyType = SymbologyType.Code128;
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                barcode.CodeText = dr["Beverages"] + "";
                byte[] imageData = barcode.drawBarcodeAsBytes();
                dr["KDBarcode"] = imageData;
            }
            CrystalReport1 rpt = new CrystalReport1();
            rpt.SetDataSource(ds);
            this.crystalReportViewer1.ReportSource = rpt;
            aConnection.Close();
        }