Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Create a random "activation code" and store it in sql server 2005

Reply
Thread Tools

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

 
 
Andy B
Guest
Posts: n/a
 
      08-08-2008
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.


 
Reply With Quote
 
 
 
 
Alexey Smirnov
Guest
Posts: n/a
 
      08-08-2008
On Aug 8, 1:46*pm, "Andy B" <(E-Mail Removed)> 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/libr...d.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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Math.random() and Math.round(Math.random()) and Math.floor(Math.random()*2) VK Javascript 15 05-02-2010 03:43 PM
Help. Getting a An error has occurred while establishing a connectionto the server. When connecting to SQL Server 2005, this failure may be causedby the fact that under the default settings SQL Server does not allow remote aboutjav.com@gmail.com ASP .Net 0 05-03-2008 12:43 PM
random.random(), random not defined!? globalrev Python 4 04-20-2008 08:12 AM
SQL Server 2005 + SQL Server Express farseer ASP .Net 3 08-08-2006 04:07 AM
Wohoo! VS.NET 2005/ASP.NET 2.0/SQL Server 2005/BizTalk Server 2006 will launch week of Nov. 7 Juan T. Llibre ASP .Net 0 06-07-2005 05:19 PM



Advertisments