Generate barcode using Visual Studio local report or SSRS
Follow below steps to generate barcode in SQL Server Reporting Services(SSRS) or Visual Studio local reports.
- Download open source ZXing.Net.0.14.0.0 component for Barcode or QRCode generation.
- Create a Visual Studio project and add a Report
- Create datasets for the report.
- Select Report and press F4 to open report properties.
- Select Properties > Code.
- Write Following code in custom code text box.
Public Function getBarCode39Horizontal(ByVal s As String) As Byte() Dim writer As New ZXing.BarcodeWriter() Dim ms AS System.IO.MemoryStream = new System.IO.MemoryStream()writer.Format = ZXing.BarcodeFormat.CODE_39 writer.Options = New ZXing.Common.EncodingOptionswriter.Options.Width = 125 writer.Options.Height = 100 Dim bmp As System.Drawing.Bitmap = writer.Write(s) bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png) Dim imagedata as byte() imagedata = ms.GetBuffer() Return imagedata End Function Public Function getBarCode39Vertical(ByVal s As String) As Byte() Dim writer As New ZXing.BarcodeWriter() Dim ms AS System.IO.MemoryStream = new System.IO.MemoryStream() writer.Format = ZXing.BarcodeFormat.CODE_39 writer.Options = New ZXing.Common.EncodingOptions writer.Options.Width = 420 writer.Options.Height = 110 Dim bmp As System.Drawing.Bitmap = writer.Write(s) bmp.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone) bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Png) Dim imagedata as byte() imagedata = ms.GetBuffer() Return imagedata End Function
- Select Reference in same property window.
- Add reference to downloaded Zxing component (zxing.dll) and System.Drwaing.
- Now add an image on report and right click on it and select Image Properties.
- In general tab select the image source as database.
- click on Fx icon of use this field combo and write following code.
=Code.getBarCode39Vertical(Fields!<database field name>.Value - In above code replace <database field name> with your report data field.
- Compile and execute the application.
If you required any further information or any sample code please contact me at arwind@adeptlab.com.
Hi there, just became aware of your blog through Google, and found that it’s really informative.
I am gonna watch out for brussels. I’ll be grateful if you continue this in future.
Lots of people will be benefited from your
writing. Cheers!
I think this is one of the most significant info for me.
And i am glad reading your article. But wanna remark on few general things, The site style is perfect, the articles is really excellent :
D. Good job, cheers
Thanks on your marvelous posting! I genuinely enjoyed reading it, you are a great author.
I will always bookmark your blog and will often come back
in the future. I want to encourage you to definitely
continue your great posts, have a nice evening!
Yoou really make iit seem so easy with you presentation but I find this matter to be actally something that I think I would never understand.
It seems ttoo complicated aand extremel broad for me.
I’m looking forward for your next post, I’ll try to get the
hang of it!