I'm not a SQL master so I'm hoping this isn't too big of an issue. :) Here's my SQL:
query = "SELECT id, email, firstName, lastName " +
"FROM [WarehouseUser] " +
"WHERE email LIKE '%' + @Filter + '%' OR FirstName LIKE '%' + @Filter + '%' OR LastName LIKE '%' + @Filter + '%'" +
"ORDER BY " + "DESC" +
"OFFSET @Offset ROWS " +
"FETCH NEXT @Length ROWS ONLY;";
When this is executed I get the following error:
System.Data.SqlClient.SqlException: 'Incorrect syntax near '@Offset'. Invalid usage of the option NEXT in the FETCH statement.'
What am I doing wrong?
You can see the problem when you output the value of your variable and look at the SQL Query it writes. Here you need a space after
"DESC"
. Like"DESC "
. You Currently are havingDESCOFFSET
instead ofDESC OFFSET
. See it here:http://rextester.com/live/RKRXM8567