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

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.
 
G

Guest

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.

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top