Last post Oct 27, 2017 05:28 AM by Deepak Panchal
Oct 26, 2017 01:40 PM|Natalie198415090|LINK
I was wondering how to create a simple leader board for the website I am creating?
I wish to list all users in order (most posts to least) and the username and number of posts will be viewable in the leader board, with the highest number of posts amount being #1 in rank, all the way down to the bottom (fewest number of posts)
The information is just inside a database table! I can't connect to the individual value to store it in the live program, then delete the value on the database, then increment the live value by
one, and insert it back into the database!
Thanks so much in advance everyone,
Oct 27, 2017 05:28 AM|Deepak Panchal|LINK
to display the leader board you first need to create a query in sql.
with the query like below you can find rank.
SELECT TOP(10) BusinessEntityID, Rate,
RANK() OVER (ORDER BY Rate DESC) AS RankBySalary
FROM HumanResources.EmployeePayHistory AS eph1
WHERE RateChangeDate = (SELECT MAX(RateChangeDate)
FROM HumanResources.EmployeePayHistory AS eph2
WHERE eph1.BusinessEntityID = eph2.BusinessEntityID)
ORDER BY BusinessEntityID;
then after you can try to display this data on your web page using grid view.
example to fire query and display data in grid view.
SqlConnection con = new SqlConnection("Data Source=.; uid=sa; pwd=abc ;database=demo_db;");
string strSQL = "Select * from table";
SqlDataAdapter dt = new SqlDataAdapter(strSQL, con);
DataSet ds = new DataSet();
GridView1.DataSource = ds;
for other example you can also refer link below.
Simple Insert Select Edit Update and Delete in ASP.Net GridView control