locked
How to select random id from database and display randomly on label RRS feed

  • Question

  • User1933868974 posted

    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 :

    using System;
    using System.Collections.Generic;
    using System.Configuration;
    using System.Data.SqlClient;
    using System.IO;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    
    
    
    public partial class _Default : System.Web.UI.Page
    {
        string constr = ConfigurationManager.ConnectionStrings["lucky"].ConnectionString;
        protected void Page_Load(object sender, EventArgs e)
        {
           
    
    
            
        }
    
        protected void Button1_Click(object sender, EventArgs e)
        {
            using (SqlConnection con = new SqlConnection(constr))
            {
                using (SqlCommand cmd = new SqlCommand(""))
                {
    
                }
            }
        }
    }
    Tuesday, March 27, 2018 7:00 AM

All replies

  • User-369506445 posted

    hi

    please try below query :

    SELECT TOP 1 id from [dbo].[myTable] ORDER BY NEWID()

    Tuesday, March 27, 2018 7:10 AM