Asyraf MN

Asyraf MN

  • NA
  • 28
  • 7.5k

How to select random id from database and display randomly o

Mar 27 2018 2:45 AM
Currently, I'm working on the Lucky Draw system. So the process of the system is when user click on button draw it select a random id from database where table attendance="Present". I also want to make the output display like animated counter number. Can anyone help me on this.Thanks.
 
I stuck on the background code :
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Configuration;  
  4. using System.Data.SqlClient;  
  5. using System.IO;  
  6. using System.Linq;  
  7. using System.Web;  
  8. using System.Web.UI;  
  9. using System.Web.UI.WebControls;
  10. public partial class _Default : System.Web.UI.Page  
  11. {  
  12.     string constr = ConfigurationManager.ConnectionStrings["lucky"].ConnectionString;  
  13.     protected void Page_Load(object sender, EventArgs e)  
  14.     {         
  15.     }
  16.     protected void Button1_Click(object sender, EventArgs e)  
  17.     {  
  18.         using (SqlConnection con = new SqlConnection(constr))  
  19.         {  
  20.             using (SqlCommand cmd = new SqlCommand("SELECT TOP 1 id from [dbo].[EMPLOYEES] ORDER BY NEWID()"))  
  21.             {  
  22.   
  23.             }  
  24.         }  
  25.     }  
  26. }  
This i my EMPLOYEES table :

Answers (2)