Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to select rows after first 10 rows, any help?

What I have tried:

con.Open();
           String sql = "SELECT * from bills order by sr_no OFFSET 10 ROWS ONLY ";
           cmd = new OleDbCommand(sql, con);
           dr1 = cmd.ExecuteReader(CommandBehavior.CloseConnection);
           dataGridView1.Rows.Clear();
           while (dr1.Read() == true)
           {
               dataGridView1.Rows.Add(dr1[0], dr1[3]);
           }
           con.Close();
Posted
Updated 28-Nov-19 2:01am

1 solution

It depends on the database you're querying.

For SQL Server 2012 or later:
SQL
SELECT * from bills order by sr_no OFFSET 10 ROWS
NB: Don't add "only" to the query.

ORDER BY Clause (Transact-SQL) - SQL Server | Microsoft Docs[^]
 
Share this answer
 
Comments
Prachi92 3-Dec-19 6:34am    
How to use OFFSET using oleDB
Richard Deeming 3-Dec-19 6:41am    
What error are you getting?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900