Generate Random Number in Asp.net

Generate Random Number in Asp.net


1)Random Number using C#

    protected void Page_Load(object sender, EventArgs e)
        {
            Random rd = new Random();
            Int32 rdNum = rd.Next();
            Response.Write(rdNum.ToString()+DateTime.Now.Millisecond.ToString());
    
        }

2)Random Number using Sql Sever

SELECT CAST(RAND() * 99999999 AS INT) AS [RandomNumber]

For more uniqueness 

SELECT cast (CAST(RAND() * 99999999 AS INT) as varchar)+cast(cast (GETDATE() as int) as varchar) AS [RandomNumber]


Comments

Popular posts from this blog

Create and save QR code in asp.net with C#

Change text of RadGrid Header Dynamically

Telerik Radwindow Open on Button Click