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.