Error with Pagination using Node.js

Using Wappler v3.9.7 on a mac with Node.js and SQL Server database.

It’s been a little while since I’ve done pagination, so it’s possible I’m doing something wrong.
I get an error 500 when I click a sortable header or a pagination link on a table where I have added pagination.

So If I create a table from the table generator with just sortable headers, it works fine. I convert my server action to a paged query, add the offset to my query manager, add the pagination and when the page initially loads, the server action is successful. However when I click on any query parameter such as a sortable header or pagination I get this error:

Here is my Server Action:

Query Manager:

Server Connect:

Any ideas what is happening? Has anyone else had this problem?

Thanks,
Chris

@George @patrick

What version of SQL server are you using? I don’t see you doing anything wrong, the error says the SQL server doesn’t understand the SQL syntax.

We are using SQL Server 2019. It seems to work fine with ASP.NET server model.

In NodeJS we use the 3rd party module knex for the actual SQL generation. In ASP(.NET)/PHP we have our own sql builder and we use a different way of paging in our queries.

I did some google search and it seems that the OFFSET/FETCH method that knex is using only works in combination with the ORDER BY. Try to add an order column in the query builder and let me know if that works.

1 Like

If I add an Order By, then it immediately gives me the error on page load. If I don’t have the Order By, it will load the server action normally, but only give me the error if I click on any query parameter such as pagination or sort.

Hi @patrick, this tip worked fine for me! Thanks!