Click here to Skip to main content
16,015,481 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can someone share me the logic of creating unique order id for shopping cart.
Posted

Try:
C#
Guid g = Guid.NewGuid();

Alternatively, you could allow SQL to generate them by using an Identity field in the DB.
 
Share this answer
 
Comments
Thanks7872 21-May-13 7:49am    
↑voted..!
You don't. You let the database create the ID for you.
 
Share this answer
 
You can use GUID to create a unique identifier to use... for further improvement or to cater the length you can mix up the GUID along with regex.


Guid guid = Guid.NewGuid();
string id = guid.ToString().Substring(0, 10);
Regex R1 = new Regex(id);
id = Regex.Replace(id, @"\s|\-|'", "");


the above mentioned code is the combination of GUID & regex, and through which a GUID of length 10 can be created. which will be completely uniqeu all the time..

Hope it will help..

:)
 
Share this answer
 
use Session.SessionID

other solution which are given to this ans are also preferable
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900