条形码生成器添加到访问2007 [英] Barcode generator add to access 2007

查看:90
本文介绍了条形码生成器添加到访问2007的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在使用条形码生成器插入MS Access 2007数据库,我只想在条形码图像下插入数字,但它给我一些错误:溢出我认为这是因为条形码的长度.Text(由位图使用)。



有没有人可以指导我修复我的问题?我只想在数据库中只添加RandomNumbers,例如:2312313123;不包括条形码图片。



这是照片我只想要记录条形码下的数字。



我该怎么办?



谢谢。



我的尝试:



Hi I was working with Barcode generator to Insert on MS Access 2007 database, I only want to insert the numbers under the barcode image, yet it gives me some error: "Overflow"I think it's because of the length of the barcode.Text (used by the bitmap).

Is there anyone who can guide me up to fix my problem? I just want to add only the RandomNumbers eg: "2312313123" on database; not included the barcode image.

This is the Photo I just want to record the numbers under the barcode.

How can I do it?

Thank you.

What I have tried:

private void GetBarcode()
       {

           string barcodes = barcode.Text = RandomDigits(12);

           Bitmap bitmap = new Bitmap(barcodes.Length * 264, 82);
           using (Graphics graphics = Graphics.FromImage(bitmap))
           {
               Font ofont = new System.Drawing.Font("IDAutomationHC39M", 14);
               PointF point = new PointF(2f, 2f);
               SolidBrush black = new SolidBrush(Color.Black);
               SolidBrush white = new SolidBrush(Color.White);
               graphics.FillRectangle(white, 0, 0, bitmap.Width, bitmap.Height);
               graphics.DrawString("*" + barcodes + "*", ofont, black, point);
           }

           using (MemoryStream ms = new MemoryStream())
           {
               bitmap.Save(ms, ImageFormat.Png);
               pictureBox1.Image = bitmap;
               pictureBox1.Height = bitmap.Height;
              // pictureBox1.Width = bitmap.Width;
           }


       }





此RandomDigits用于生成条形码图像。



This RandomDigits is use to generate the barcode image.

public string RandomDigits(int length)
       {
           var random = new Random();
           string s = string.Empty;
           for (int i = 0; i < length; i++)
               s = String.Concat(s, random.Next(10).ToString());
           return s;
       }

推荐答案

您说要将数字放在数据库中,但是您显示的代码生成条形码图像,直接调用生成条形码编号的方法。



我认为解决方案非常明显。让调用它的代码直接调用RandomDigits FIRST,然后该代码将字符串传递给生成条形码图像的代码。这样,你有两条信息!



哦,你的GetBarcode方法没有返回类型,所以它根本不返回任何内容。如果你要命名你的方法Get ...,他们应该总是返回一些东西。您的GetBarcode不应设置图片框图像。它应该返回一个Bitmap图像。调用它的代码可以决定是否要在图片框中显示图像。
You say you want to put the numbers in a database, but the code you show generates a barcode image, which directly calls the method that generates the barcode number.

I think the solution is quite obvious. Have the code that calls this directly call RandomDigits FIRST, then that code passes the string to the code that generates the barcode image. That way, you have both pieces of information!

Oh, and your GetBarcode method doesn't have a return type, so it returns nothing at all. If you're going to name your methods Get..., they should always return something. Your GetBarcode should NOT set a picturebox image. It should return a Bitmap image. The code that calls this can then decide if it want to show the image in a picturebox or not.


它已经解决了,谢谢你的回复。
It has been solved, thank you for the reply.

这篇关于条形码生成器添加到访问2007的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆