Barcode for Crystal Report > Generate Barcode in Crystal Report

How to Generate Barcodes in Crystal Reports

Print Multiple 1D & 2D Barcodes for Crystal Reports Using Free Barcode Generator Demo
  • Advanced barcode generator control to display high-quality barcodes in Crystal Reports
  • Totally integrated with .NET framework 2.0, 3.0, 3.5 and above versions
  • Compatible with latest corresponding barcode specifications or standards
  • Easy to use, simple to install for .NET Crystal Reports barcode generation and creation
  • User-friendly tutorial & interface to make adjustments for the generated barcode images on Crystal Reports
  • Support generating barcodes in various image formats including Png, Gif, Jpg, Bmp & Tiff
  • Resolution adjustable to print accustomed barcode pictures suitable for all printers
Download KA.Barcode for Crystal Reports
Time Limitation
You can use this free trial version of KA.Barcode for Crystal Reports infinitely.
Limits of Evaluation
Linear and 2D barcode images generated with this free trial version of KA.Barcode for Crystal Reports will contain a "KA Barcode" watermark. Therefore, they cannot be used for commercial applications. Only demo/evaluation implementation is allowed. Please purchase a provided license for other applications.
Generate Barcode in Crystal Reports for Web Forms Project
  1. Create a new web project with "ASP.NET Crystal Reports Web Site" as template in Visual Studio.
  2. Create a new report "Using the Report Wizard", choose "Standard", and click "OK".
  3. In "Data" form, double click "Create New Connection", and expand "ADO.NET".
  4. In "ADO.NET" form, select "ProductDataSet.xsd" file in your downloaded package, and click "Finish" button.
  5. In "Data" form, add table "Product" and click "Next". In "Fields" form, add all three columns in the table "Product" and click "Finish".
  6. In CrystalReport1.rpt, add field "Barcode" to the report Section 3.
  7. Add "KeepAutomation.Barcode.Crystal.dll" to your project reference in "Solution Explorer".
  8. Copy the sample code accordingly and run the project.
C# Sample code
     protected void Page_Load(object sender, EventArgs e)
{
{
//create the database connection. Please change to correct data file (BarcodeDemoData.mdb) path.
OleDbConnection aConnection = new OleDbConnection
("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/KACrystalData.mdb ");
aConnection.Open();

OleDbDataAdapter dataAdapter = new OleDbDataAdapter("select * from Product", aConnection);
DataSet ds = new DataSet();
dataAdapter.Fill(ds);

//Add the Barcode column to the DataSet
ds.Tables[0].Columns.Add(new DataColumn("Barcode", typeof(byte[])));

//Create an instance of Linear Barcode
//Use DataMatrixCrystal for Data Matrix
//Use PDF417Crystal for PDF417
//Use QRCodeCrystal for QR Code
BarCode barcode = new BarCode();
//Barcode settings
barcode.Symbology=KeepAutomation.Barcode.Symbology.Code128Auto;
barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;

foreach (DataRow dr in ds.Tables[0].Rows)
{
barcode.CodeToEncode = (int)dr["ProductId"] + "";
byte[] imageData = barcode.generateBarcodeToByteArray();
dr["Barcode"] = imageData;
}
CrystalReportSource1.ReportDocument.Load(Server.MapPath("CrystalReport1.rpt"));
CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables[0]);
CrystalReportSource1.DataBind();

}

}
}
VB Sample code
     'create the database connection. Please change to correct data file      (BarcodeDemoData.mdb) path.
Dim aConnection As New OleDbConnection
("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:/KACrystalData.mdb ")
aConnection.Open()

Dim dataAdapter As New OleDbDataAdapter("select * from Product", aConnection)
Dim ds As New DataSet()
dataAdapter.Fill(ds)

'Add the Barcode column to the DataSet
ds.Tables(0).Columns.Add(New DataColumn("Barcode", GetType(Byte())))

'Create an instance of Linear Barcode
'Use DataMatrixCrystal for Data Matrix
'Use PDF417Crystal for PDF417
'Use QRCodeCrystal for QR Code
Dim barcode As New BarCode()
'Barcode settings
barcode.Symbology = KeepAutomation.Barcode.Symbology.Code128Auto
barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png

For Each dr As DataRow In ds.Tables(0).Rows
barcode.CodeToEncode = CInt(dr("ProductId")) & ""
Dim imageData As Byte() = barcode.generateBarcodeToByteArray()
dr("Barcode") = imageData

CrystalReportSource1.ReportDocument.Load(Server.MapPath("CrystalReport1.rpt"))
CrystalReportSource1.ReportDocument.SetDataSource(ds.Tables(0))
CrystalReportSource1.DataBind()
Generate Barcode in Crystal Reports for WinForms Project
  1. Create a new .NET project with "Crystal Reports Application" as template.
  2. Create a new report "Using the Report Wizard", choose "Standard", and click "OK" button.
  3. In "Data" form, expand "Create New Connection", and expand "ADO.NET".
  4. In "Connection" form, select the "ProcudtDataSet.xsd" in your downloaded sample dataset package. Then click "Finish" button.
  5. In "Data" form, add table "Customer" and click "Next". In "Fields" form, add all three columns in the table "Product", and click "Finish".
  6. In CrystalReport1.rpt, drag and drop "Barcode" in "Field Explorer" to the report Section 3.
  7. In .NET project "solution explorer", add "KeepAutomation.Barcode.Crystal.dll" to your project reference.
  8. Open your "Form1.cs", and copy the following code into the method Form1_Load and run the report.
C# Sample code
     OleDbConnection aConnection = new      OleDbConnection
("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:/KACrystalData.mdb");
aConnection.Open();
OleDbDataAdapter dataAdapter = new OleDbDataAdapter("select * from Product", aConnection);
DataSet ds = new DataSet();
dataAdapter.Fill(ds);
//add a new column named "Barcode"to the DataSet, the new column data type is byte[]
ds.Tables[0].Columns.Add(new DataColumn("Barcode", typeof(byte[])));
BarCode barcode = new BarCode();
barcode.Symbology=KeepAutomation.Barcode.Symbology.Code39;
barcode.ImageFormat=System.Drawing.Imaging.ImageFormat.Png;

foreach (DataRow dr in ds.Tables[0].Rows)
{
barcode.CodeToEncode = (int)dr["ProductId"] + "";
byte[] imageData = barcode.generateBarcodeToByteArray();
dr["Barcode"] = imageData;

}

CrystalReport1 rpt = new CrystalReport1();
rpt.SetDataSource(ds);
this.crystalReportViewer1.ReportSource = rpt;
aConnection.Close();
VB Sample code
     Dim aConnection As New OleDbConnection
("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:/KACrystalData.mdb")
aConnection.Open()
Dim dataAdapter As New OleDbDataAdapter("select * from Product", aConnection)
Dim ds As New DataSet()
dataAdapter.Fill(ds)
'add a new column named "Barcode"to the DataSet, the new column data type is byte[]
ds.Tables(0).Columns.Add(New DataColumn("Barcode", GetType(Byte())))
Dim barcode As New KeepAutomation.Barcode.Crystal.BarCode()
barcode.Symbology = KeepAutomation.Barcode.Symbology.Code39
barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png

For Each dr As DataRow In ds.Tables(0).Rows
barcode.CodeToEncode = CInt(dr("ProductId")) & ""
Dim imageData As Byte() = barcode.generateBarcodeToByteArray()

dr("Barcode") = imageData

Dim rpt As New CrystalReport1()
rpt.SetDataSource(ds)
Me.CrystalReportViewer1.ReportSource = rpt
aConnection.Close()
Download Free Trial In Web Crystal ReportsIn Windows CrystalUsing C#Using VB.NETUsing ASP.NETUsing .NET WinformsData Matrix for Crystal ReportPDF417 for Crystal ReportQR Code for Crystal ReportmoreCodabar for Crystal ReportCode 39 for Crystal ReportCode 128 for Crystal ReportEAN-8 for Crystal ReportEAN-13 for Crystal ReportEAN 128 for Crystal ReportIntelligent Mail for Crystal ReportInterleaved 2 of 5 for Crystal ReportISBN for Crystal ReportITF-14 for Crystal ReportRM4SCC for Crystal ReportUPC-A for Crystal ReportUPC-E for Crystal Reportmore
KeepAutomation provides complete barcode automation solutions for Business Application, Enterprise Developement Project, and mobile applications. We recommend the customers use high quality .net image viewer sdk, c# image viewer, vb.net image viewer, C# PDF document viewer, VB.NET PDF document viewer, C# Word document viewer, VB.NET Word document viewer, C# Tiff image viewer, VB.NET Tiff image viewer from RasterEdge.com.