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
Post a Comment