I have 500 record in my database but using sql i can only load 250 records. If I write a query SELECT TOP 500 I get an error - Is there a way i can select top 100 record store 400 somewhere else and when a user clicks next button load another 100 etc...
public List<m> DisplayAll()
{
int yr= DateTime.Now.Year;
DateTime d= new DateTime(yr, 9, 1);
DateTime dd= new DateTime(yr+ 1, 9, 1);
List<m> l = new List<m>();
SqlConnection conn = new SqlConnection(connection...);
SqlCommand command = new SqlCommand("select distinct ID, name,sname, etc.. from TableName where Time > @Time And Time < @Time1 ORDER BY ID, name, sname, etc... OFFSET 10 ROWS FETCH NEXT 100 ROWS ONLY", conn);
command.Parameters.AddWithValue("@Time", d);
command.Parameters.AddWithValue("@Time1 ", dd);
I am getting an error "Incorrect syntax near 'OFFSET'."
在SQL Server中,从2005开始,您使用ROW_NUMBER()并按该结果进行过滤,例如BETWEEN 1 AND 100
等。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.