Mid From PDF ADO.NET ADO.NET

Use Paging: Instead of loading all the records at once, retrieve data in chunks (or pages) using SQL's LIMIT, OFFSET, or TOP clauses. You can implement paging on both the server side (in the SQL query) and the client side (in the ASP.NET

pplication).

Example (Using Paging in SQL):

string query = "SELECT * FROM Customers ORDER BY CustomerID OFFSET

@Offset ROWS FETCH NEXT @PageSize ROWS ONLY";

SqlCommand command = new SqlCommand(query, connection);

command.Parameters.AddWithValue("@Offset", pageNumber * pageSize);

command.Parameters.AddWithValue("@PageSize", pageSize);

connection.Open();

SqlDataReader reader = command.ExecuteReader();

while (reader.Read())

{

// Process data

}

reader.Close();

connection.Close();

More from ADO.NET Core Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details