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

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

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:
    611
    Juan T. Llibre
    Jun 7, 2005
  2. =?Utf-8?B?c2NvdHRybQ==?=

    sql session state for .net v1.1/.net v2.0 and sql server 2005

    =?Utf-8?B?c2NvdHRybQ==?=, Feb 13, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    2,958
    Steven Cheng[MSFT]
    Feb 16, 2006
  3. farseer

    SQL Server 2005 + SQL Server Express

    farseer, Aug 7, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    511
    farseer
    Aug 8, 2006
  4. Brad  Brening
    Replies:
    0
    Views:
    603
    Brad Brening
    Mar 1, 2007
  5. globalrev
    Replies:
    4
    Views:
    1,039
    Gabriel Genellina
    Apr 20, 2008
  6. Wesley Chen
    Replies:
    0
    Views:
    365
    Wesley Chen
    Apr 7, 2009
  7. Wesley Chen
    Replies:
    9
    Views:
    480
    Sean O'Halpin
    Apr 14, 2009
  8. VK
    Replies:
    15
    Views:
    1,834
    Dr J R Stockton
    May 2, 2010
Loading...