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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy B

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

    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.


  • Alexey Smirnov

    #2
    Re: Create a random "activatio n code" and store it in sql server 2005

    On Aug 8, 1:46 pm, "Andy B" <a_bo...@sbcglo bal.netwrote:
    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.New Guid(). It creates a string like a55954b3-
    f858-4f83-82a9-38422b10168d



    For example,

    string key = System.Guid.New Guid().ToString ().Replace("-",
    string.Empty).S ubstring(0, 12);

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

    Comment

    Working...