Select and display recent (newest) record in ASP.Net Core MVC

Last Reply 4 days ago By dharmendr

Posted 5 days ago

How to select recent record and display in label in asp.net core mvc 

I don't have any DateTime column.

I have id, name, age column only.

Posted 4 days ago Modified on 4 days ago

Hi rani,

You can use TOP caluse to select one record by using Order By Descending if its identity column.

SELECT TOP 1 * FROM Students ORDER BY Id DESC

Use the query in your SqlCommand.

If you dont have identity column then you need to addd the DateTime column to identify the last added record.