In the following Step-By-Step Guide we're going to create a Crystal Report which features barcoding capabilities by using Barcode Professional SDK for .NET and using as data source for the report a Typed DataSet.
Neodynamic Barcode Professional SDK 1.0 (or greater) for .NET
Microsoft .NET Framework 2.0 (or greater)
Microsoft Visual Studio 2005/2008
Microsoft SQL Server 2005 (any version) with Northwind Database sample installed
Crystal Reports for Visual Studio .NET 2005/2008
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Filling Products DataTable from DB
Dim ta As New NorthwindTableAdapters.ProductsTableAdapter()
Dim dt As New Northwind.ProductsDataTable()
ta.Fill(dt)
'Create an instance of Barcode Professional
Dim bcp As New Neodynamic.SDK.BarcodeProfessional()
'Barcode settings
bcp.Symbology = Neodynamic.SDK.Symbology.Code39
bcp.Extended = true
bcp.AddChecksum = false
bcp.BarHeight = 0.4f
'Append fictitious Company internal prefix
Dim prodPrefix As String = "12345"
Dim row As Northwind.ProductsRow
For Each row In dt.Rows
'Set the value to encode
bcp.Code = prodPrefix + row.ProductID.ToString()
'Generate the barcode image and store it into the Barcode Column
row.Barcode = bcp.GetBarcodeImage(System.Drawing.Imaging.ImageFormat.Png)
Next
'Create a report object
'and set its data source with the DataSet
Dim report As New CrystalReportBarcode()
report.SetDataSource(CType(dt, DataTable))
Me.CrystalReportViewer1.ReportSource = report
End Sub
private void Form1_Load(object sender, EventArgs e)
{
//Filling Products DataTable from DB
NorthwindTableAdapters.ProductsTableAdapter ta = new NorthwindTableAdapters.ProductsTableAdapter();
Northwind.ProductsDataTable dt = new Northwind.ProductsDataTable();
ta.Fill(dt);
//Create an instance of Barcode Professional
Neodynamic.SDK.BarcodeProfessional bcp = new Neodynamic.SDK.BarcodeProfessional();
//Barcode settings
bcp.Symbology = Neodynamic.SDK.Symbology.Code39;
bcp.Extended = true;
bcp.AddChecksum = false;
bcp.BarHeight = 0.4f;
//Append fictitious Company internal prefix
string prodPrefix = "12345";
//Update DataTable with barcode image
foreach (Northwind.ProductsRow row in dt.Rows)
{
//Set the value to encode
bcp.Code = prodPrefix + row.ProductID.ToString();
//Generate the barcode image and store it into the Barcode Column
row.Barcode = bcp.GetBarcodeImage(System.Drawing.Imaging.ImageFormat.Png);
}
//Create a report object
//and set its data source with the DataSet
CrystalReportBarcode report = new CrystalReportBarcode();
report.SetDataSource((DataTable)dt);
this.crystalReportViewer1.ReportSource = report;
}
Tweet |
|
We provide best-in-class customer service and support directly from members of our dev team! If we are available when you contact us, you will get a response in few minutes; otherwise the maximum turnaround is 24hs in most cases.