Mid 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

application).

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

Follow:

reader.Close();

connection.Close();

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