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

Discussion in 'ASP .Net' started by Andy B, Aug 8, 2008.

  1. Andy B

    Andy B 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.
     
    Andy B, Aug 8, 2008
    #1
    1. Advertising

  2. On Aug 8, 1:46 pm, "Andy B" <> wrote:
    > 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
     
    Alexey Smirnov, Aug 8, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Juan T. Llibre
    Replies:
    0
    Views:
    473
    Juan T. Llibre
    Jun 7, 2005
  2. farseer

    SQL Server 2005 + SQL Server Express

    farseer, Aug 7, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    350
    farseer
    Aug 8, 2006
  3. globalrev
    Replies:
    4
    Views:
    778
    Gabriel Genellina
    Apr 20, 2008
  4. Wesley Chen
    Replies:
    0
    Views:
    229
    Wesley Chen
    Apr 7, 2009
  5. VK
    Replies:
    15
    Views:
    1,189
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page