wyrd Posted June 12, 2003 Posted June 12, 2003 - What's the best way to produce UPC, VIN, ISBN, or SKU codes for products? - Is there a URL where I can read up on how to implement such things into my program to uniquely identify products? Right now I have it where the user uses UPC, VIN, ISBN, or SKU codes from the wholesaler for items they buy, however I need a way to create a unique code for items that the user creates on their own. I have an implementation that works fine for now, but I seriously doubt it follows the standards of UPC, VIN, ISBN, or SKU codes. Quote Gamer extraordinaire. Programmer wannabe.
Moderators Robby Posted June 12, 2003 Moderators Posted June 12, 2003 VIN and ISBN are specific to their respective industries. UPC can be whatever you want it to be. You can do something like DTWAQC0052536 DT = product type WA = category QC = whatever 0052536 = incremented by the database I'm not thinking deeply about my reply but you get the idea. Quote Visit...Bassic Software
wyrd Posted June 12, 2003 Author Posted June 12, 2003 (edited) Hmm, I see. As a temp thing I just did the format: YYMMDDHHMMSSC It's basically the current date and time with C at the end (stands for code). Example: 030611062402C A bit cryptic indeed, but it does tell you when the item was created. :) I think I like your suggested a bit better, maybe I'll work on a mix between the two. WA30611062402 or something. The thing about the "incremented by the database" part is that I'd have to connect to the database and count how many items in the specific category/type already exist. Not sure if I really care to do that. With date/second format I can just create it on the fly and I'm always guaranteed that it'll be unique (until the year 2103 anyway). Oh, and is there a maximum length in which UPC codes must not exceed? EDIT: BTW, you sure you didn't mean SKU codes can be anything I wanted? I thought UPC codes are 12 digit bar codes. Edited June 12, 2003 by wyrd Quote Gamer extraordinaire. Programmer wannabe.
hog Posted June 12, 2003 Posted June 12, 2003 Wyrd, might be off beam here but could you not store the last 'incremented code' that was created? I may not be reading you thread properly however :) Quote My website
ThePentiumGuy Posted June 12, 2003 Posted June 12, 2003 try a random number generator lets say the UPC format's like this:( correct me if im wrong) NNNNN-NNNN-NNNN N means any number use a random number generator and say something link label1.text = RND1-RND2-RND3 make sure RND1 has 5 digits, RND2 has 4 digits and RND 3 has 4 digits Quote My VB.NET Game Programming Tutorial Site (GDI+, Direct3D, Tetris [coming soon], a full RPG.... you name it!) vbprogramming.8k.com My Project (Need VB.NET Programmers) http://workspaces.gotdotnet.com/ResolutionRPG
wyrd Posted June 12, 2003 Author Posted June 12, 2003 Wyrd, might be off beam here but could you not store the last 'incremented code' that was created? I may not be reading you thread properly however :) If I used pure digits, then yes that would be easy enough to do. However since I won't be doing that and using letters, it's impossible to just grab the last number used. There is a work around that I thought of, and that's storing the item code into two seperate database columns (Product_Type and Product_Number), however that would cause some serious problems later on. So, the only alternative I have is to use a quick selection COUNT(*) based on Product_Type LIKE 'DT%'. This probably isn't all that bad as it would be fairly quick, it's just that I don't like making round trips to the database when I don't have to. Storing all products in memory is not an option either. Unless someone can point a flaw in my item code generation (WA30611062402 - based of product type and current date/time) I see no reason not to use it. Quote Gamer extraordinaire. Programmer wannabe.
*Gurus* divil Posted June 13, 2003 *Gurus* Posted June 13, 2003 I use guids all the way :) Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.