Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Barcodes Code128 generator function Expand / Collapse
Author
Message
Posted Friday, February 11, 2011 5:32 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, May 15, 2013 10:55 AM
Points: 67, Visits: 265
I'm looking for a barcode generating Function (in SQL 2005), that uses the standard Code128.

The result of calling the function will then be mailmerged in Word in a document with font Code128.TTF (this shows the barcode as such).

Now, the problem is that I have the correct function in Access (code attached in TXT) but not in SQL Server.

Does anyone have the equivalent SQL Server function (or knows how to translate this Access into SS) ?

Thanks in advance, a.


  Post Attachments 
basCode128.txt (46 views, 3.77 KB)
Post #1062489
Posted Friday, February 11, 2011 6:12 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 3:24 PM
Points: 11,605, Visits: 27,649
a quick google lead me to this solution posted from Dalton from http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=70901

declare @myString varchar(255)
select @myString = 'BarCode 1'

-- Define the string of characters that we'll need to pull the reference of
declare @asciiString varchar(255)
select @asciiString = ' !"#$%&''()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'
select @asciiString = @asciiString + char(195) -- 0xC3
select @asciiString = @asciiString + char(196) -- 0xC4
select @asciiString = @asciiString + char(197) -- 0xC5
select @asciiString = @asciiString + char(198) -- 0xC6
select @asciiString = @asciiString + char(199) -- 0xC7
select @asciiString = @asciiString + char(200) -- 0xC8
select @asciiString = @asciiString + char(201) -- 0xC9
select @asciiString = @asciiString + char(202) -- 0xCA
-- Define the stop and start characters
declare @stopchar char(1)
declare @startchar char(1)
declare @spacechar char(1)
select @stopchar = char(206) -- 0xCE
select @startchar = char(204) -- 0xCC
select @spacechar = char(194) -- 0xC2

-- Define the final holding place of our output string
declare @finalArray varchar(255)

-- Define the variables that we'll need to be using
declare @checksumTotal int
declare @checksum int
select @checksumTotal = 104;
select @checksum = 0;

-- Start building our output
select @finalArray = @startchar

-- Loop through our input variable and start pulling out stuff
declare @position int
declare @thisChar char(1)
select @position = 1
while @position <= len(@myString)
begin
select @thisChar = substring(@myString, @position, 1)
select @checksumTotal = @checksumTotal + (@position * (ascii(@thischar)-32))
select @finalArray = @finalArray + @thisChar
select @position = @position + 1
end -- We've gone past the length now

-- Now we need to figure out and add the checksum character
select @checksum = @checksumTotal % 103
if @checksum = 0
select @finalArray = @finalArray + @spacechar
else
-- Barcorde array assumes 0 as initial offset so we need to add 1 to checksum
select @finalArray = @finalArray + substring(@asciiString, @checksum+1, 1)
-- Now we append the stop character
select @finalArray = @finalArray + @stopchar

-- The @final Array represents the barcode encoded string
select @finalArray



Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1062506
Posted Friday, February 11, 2011 7:29 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Wednesday, May 15, 2013 10:55 AM
Points: 67, Visits: 265
Thanks Lowell, but it doesn't seem to be the same standard I'm referring to.

In standard Code128, if you code 'bananas', you'll get ÑbananasÈÓ (it always starts with capital Ñ and ends with Ó).

Pass 'bananas' to this function and you'll get 'š' and a weird character in the end... they must be pretty similar standards, but not equal.
Post #1062574
Posted Friday, March 09, 2012 6:38 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, March 09, 2012 6:32 PM
Points: 1, Visits: 0
try this code128 barcode encoder dll for sql, hope it helps!
Post #1264667
Posted Thursday, March 15, 2012 3:53 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, March 15, 2012 3:45 AM
Points: 1, Visits: 0
Hey!
I am not sure whether you have solve the problem or not. I just see thici post right moment. I've ever seen this problem, however, I found a Code 128 generator for SQL supporting service which is easy and simpe to install and use. I have just find the page from onbarcode. Any one who need may have a try in the future.

Good luck!
wang
Post #1267332
Posted Tuesday, October 16, 2012 8:51 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, December 11, 2012 9:01 PM
Points: 4, Visits: 10
I am using the bar code library for SSRS here, it could print Code 128 in reports, you may have a try.

Barcode Source Expert for barcode generation in .NET
Post #1373604
Posted Friday, December 28, 2012 7:23 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, February 03, 2013 6:58 PM
Points: 4, Visits: 6
It is quite easy to encode Code 128 barcode image in TTF format into SSRS. I tried one barcode control and it integrates easily with webform app or winform apps.
Post #1401107
Posted Sunday, January 06, 2013 12:48 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, February 17, 2013 1:56 AM
Points: 3, Visits: 7
.NET Code 128 CRI Component for SSRS is a custom report item control which stays on reports even on the redistributed ones. Free trial package and optional VB or C# sample codes are provide by this advanced control.
Barcode Generator for SSRS is a fully-integrated report item control which helps you render high quality Code 128 images into SQL Server Reporting Services. This easy-to-use control could be added as item on Visual Studio Toolbox then dragged and dropped onto your reports.
Post #1403310
Posted Monday, March 18, 2013 12:47 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, March 18, 2013 12:42 AM
Points: 1, Visits: 0
How about this .NET Code 128 barcode generator SDK? I used this before. It's easy to use, for it provides detailed tutorial of creating barcode in .NET.
Post #1432088
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse