Spire.Barcode is a professional barcode library specially designed for .NET developers (C#, VB.NET, ASP.NET, .NET Core) and Java developers (J2SE and J2EE) to generate, read and scan 1D & 2D barcodes.

Wed Sep 03, 2014 5:06 am

I have tried to create barcode in a web page and I was successful in it. Thanks to e-iceblue team. Now i am unable to use barcode in rdlc reports of ASP.Net. Kindly help me with the source code for creating barcode in rdlc reports.

amitlove98
 
Posts: 3
Joined: Wed Sep 03, 2014 4:43 am

Wed Sep 03, 2014 6:43 am

Hello,

Sorry that at present we couldn't integrate directly our Spire.Barcode with Report. But you can create the barcode image for your data via Spire.BarCode and display it in the cells of Report by yourself.

Thanks And Regards,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Wed Sep 03, 2014 10:24 am

for (int i = 1; i <= PrdWiseTotalMC; i++)
{

// BarcodeStr = OrderRefNo + Convert.ToString("PartyCd")+Convert.ToString("TotalMC")+"CWK"+Convert.ToString("RunningSrNo");
BarcodeStr = OrderRefNo + PartyCd + totalMC.ToString() + "CWK" + RunningSrNo.ToString();


BarCodeControl1.Data = BarcodeStr;
BarCodeControl1.Data2D = BarcodeStr;

BarCodeControl1.X = 0.2f;
BarCodeControl1.Unit = GraphicsUnit.Millimeter;
BarCodeControl1.HasBorder = true;
BarCodeControl1.BorderWidth = 0.5F;


BarCodeControl1.Type = Spire.Barcode.BarCodeType.Code128;

BarCodeControl1.SaveToFile("C:\\RemoteQuery\\test.png", ImageFormat.Png);
System.Diagnostics.Process.Start("C:\\RemoteQuery\\test.png");


System.Drawing.Image img = System.Drawing.Image.FromFile(@"C:\\RemoteQuery\\test.png");
byte[] bytes;
using (MemoryStream ms = new MemoryStream())
{
img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
bytes = ms.ToArray();
}


SqlCommand cmd3 = new SqlCommand("GenerateBarcodefromInages", con3);
cmd3.CommandType = CommandType.StoredProcedure;
cmd3.CommandTimeout = 600;
cmd3.Parameters.Add(new SqlParameter("@orderRefNo", DropDownList1.SelectedItem.Value));
cmd3.Parameters.Add("@PartyCd", SqlDbType.VarChar, 10).Value = PartyCd;
cmd3.Parameters.Add("@SrNo", SqlDbType.Int).Value = RunningSrNo;
cmd3.Parameters.Add("@PrdCd", SqlDbType.VarChar, 10).Value = localprdcd;
cmd3.Parameters.Add("@TotalMC", SqlDbType.Int).Value = totalMC;
// Barcode as parameter
cmd3.Parameters.Add("@Barcode", SqlDbType.Image, 16).Value = bytes;
cmd3.Parameters.Add("@GrpCd", SqlDbType.VarChar, 10).Value = "CKR";
cmd3.Parameters.Add("@PrdWiseSrNo", SqlDbType.Int).Value = i;
cmd3.Parameters.Add("@PrdWiseTotalMC", SqlDbType.Int).Value = PrdWiseTotalMC;
InsertFlag = cmd3.ExecuteNonQuery();

RunningSrNo++;

}



Sir your solution works perfectly but then when I am using "FOR" loop for generating barcodes for nearly 500 records that I am having in one of the tables of the database then only the 1st record is getting inserted and I am prompted with an error message "A Generic error occured in GDI+". Kindly provide a solution for the same.

amitlove98
 
Posts: 3
Joined: Wed Sep 03, 2014 4:43 am

Thu Sep 04, 2014 2:11 am

Hello,

Please dispose the image object after looping once, in addtion, our product provide the method to save the barcode to MemoryStream you can use.
Code: Select all
BarCodeControl1.Type = Spire.Barcode.BarCodeType.Code128;
byte[] bytes;
using (MemoryStream ms = new MemoryStream())
                {
                    BarCodeControl1.SaveToStream(ms, System.Drawing.Imaging.ImageFormat.Png);
                    bytes = ms.ToArray();
                }

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Thu Sep 04, 2014 5:31 am

Thank you Gary Zhang Sir.Your solution worked perfectly.

amitlove98
 
Posts: 3
Joined: Wed Sep 03, 2014 4:43 am

Thu Sep 04, 2014 6:33 am

Hello,

Thanks for your prompt reply. Glad to hear that.

If there are any questions, welcome to get it back to us.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.BarCode