Create a random "activation code" and store it in sql server 2005

  • Thread starter Thread starter Andy B
  • Start date Start date
A

Andy B

I am making a web application that would randomly create an activation code
and put it in a database. The web application would then send it in an email
to the user with a link to go to and enter the activation code. How would I
do this? and what sql server data type would I use? I want the activation
code to be no longer than 12 characters, have a mix of numbers and letters
and have no special symbols.
 
I am making a web application that would randomly create an activation code
and put it in a database. The web application would then send it in an email
to the user with a link to go to and enter the activation code. How wouldI
do this? and what sql server data type would I use? I want the activation
code to be no longer than 12 characters, have a mix of numbers and letters
and have no special symbols.

If you want to create it in the code then you can use
System.Guid.NewGuid(). It creates a string like a55954b3-
f858-4f83-82a9-38422b10168d

http://msdn.microsoft.com/en-us/library/system.guid.newguid.aspx

For example,

string key = System.Guid.NewGuid().ToString().Replace("-",
string.Empty).Substring(0, 12);

or you can create an own function, or you can create a function in sql
 
Back
Top