Skip 5 rows and fetch the next 5

0

I am trying to skip the first 5 rows then fetch the next 5, i'm using this for a page system. However something is wrong with my command. I rarely use databases because I get lazy and I hope somebody can help me with this.

I've tried putting the brackets around the columns i'm selecting in case any were protected and I tried adding offset 5 rows to the end of the statement.

strSQL = "SELECT [ID], [AuthorName], [AuthorID], [Title], [Content], [Views], [Replies], [LatestTime] FROM [Threads] ORDER BY [ID] DESC offset 5 rows";

When I run this code I get an error page with the message:

IErrorInfo.GetDescription failed with E_FAIL(0x80004005).

and obviously the error is where the command is executing.

c#
ms-access
oledb
asked on Stack Overflow Jun 4, 2019 by Logan Risen • edited Jul 10, 2019 by Erik A

1 Answer

0

I figured this out thanks to user https://stackoverflow.com/users/3401554/ben, what I did is not the most efficient it but it works for forums. I did my page number * the amount of threads per page, then I got the top records from the DB and skipped all the records in the reader till I reached the last 10.

answered on Stack Overflow Jun 4, 2019 by Logan Risen

User contributions licensed under CC BY-SA 3.0