Home  >  Crystal Reports Barcode Creator Control  >  Barcode Creation Guide for Crystal Reports
Crystal Reports Barcode Generator Tutorial
Crystal Reports Barcode Generator integrates various barcodes generation features into Crystal Reports. It can create, generate linear and 2D barcodes in Crystal Reports. And it is the most affordable .NET barcode generator for .NET professionals.
Crystal Reports Barcode Generator Supportive Barcodes
Crystal Reports Barcode Generator supports 20+ 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 with .NET Barcode Generator SDK in .NET Framework application. In the tutorial, we create a dataset and insert a new field to take barcode image. Then we will compose a few lines code in C# to process rows in dataset and generate barcode image from inserted field when load Crystal Reports application.
We are going to use .NET Crystal Reports Barcode Generator Library to create barcode images on Crystal Reports in Microsoft Visual Studio 2005. Please see details as below.
  1. Start Microsoft Visual Studio 2005. Create a Crystal Reports application by choosing File>New>Project. Select 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", and then select "Finish";

  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 .NET 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 your 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();
   }