VB.NET

Moderators: seancampbell
Number of threads: 3879
Number of posts: 9845

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Generate a transaction id Posted by azdonald on 15 Dec 2009 at 8:27 AM
Hi please i would like to generate a transaction id for my application something like TR1234 and i want it to be serially. The application is a server/client application. How do i go about it???
Report
Re: Generate a transaction id Posted by seancampbell on 15 Dec 2009 at 9:54 AM
Serially? As in you would like the number to be a series?

Not sure exactly what you are looking for, but from my experience, Transaction IDs have some form of "smart number" capabilities, and usually involve a structure.

For instance, a number like 063-554-4958582 could mean: 063 is a store location, 554 is the money type for the transaction, 4958582 is the transaction # for this year (the first transaction being xxx-xxx-0000001)

In this case, I would first identify all information I want to get from my conf-number, I would then create a smart number system for each part of the transaction ID, (00A = Monday, 4R = UTAH, 001 = JANUARY) these sorts of things...

Next I would identify a place to keep a running total of the transactions and store additional information about them (whatever I needed for my scenario).

Each section of the transaction ID should be a separate field in the TRANSACTION_ID table, and they should be all combined into one line in the TransID Field of any table refering to that information

Hope this helps,
Sean
Report
Re: Generate a transaction id Posted by azdonald on 17 Dec 2009 at 2:01 AM
Well i thought of selecting the last inserted transaction id and probably add one to it when the form loads but its a client/server app running on several machines so i figured it wont be a bad idea cos it will over work the server creating unnecessary connections and so on.
Your idea seems ok but i dont really have a criteria for the transid. i just want a bunch of unique numbers.
Report
Re: Generate a transaction id Posted by seancampbell on 17 Dec 2009 at 6:24 AM
If you are looking for a unique identifier, a field that can declare a record in a database unique, you can try using a GUID.

Globally Unique ID - GUID

GUIDs are 36 characters long (32 numbers 4 dashes I think), and can be stored in nvarchar fields or in Unique Identifier fields in the database. If you are using SQL Server you can create a field, and set it to UniqueIdentifier, then in the properties set "isRowGuid" to True and it will automatically generate a GUID for that row when a record is added.

You can generate GUIDs with Vb.Net as well:
Dim MyGuid As String = Guid.NewGuid.ToString()
'OR
Dim MySecondGuid As Guid = Guid.NewGuid()


hope this helps,
Sean C



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.