Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Fabian 68 posts 172 karma points
    Oct 25, 2016 @ 16:22
    Fabian
    0

    PetaPoco Page method returning You have an error in your SQL syntax error while Fetch or Query Methods run just fine

    Hi Everyone,

    I have encountered a very strange issue where when I try to load some data through the Page method of PetaPoco an error is thrown, saying the following: "You have an error in your SQL syntax". Here below is an example:

    var properties = db.Page<PropertyListingItemPartialModel>(currentPageNumber, pageSize, sqlQuery);
    

    While when I use the Fetch or Query methods, everything runs just fine without any errors. Here below is an example:

    var propertiesTest1 = db.Fetch<PropertyListingItemPartialModel>(currentPageNumber, pageSize, sqlQuery);
    var propertiesTest2 = db.Query<PropertyListingItemPartialModel>(sqlQuery);
    

    I have checked my SQL query and cannot spot any mistakes and I believe if there was, it will not work either way and not just when using the Page method.

    Does anybody have a clue why this is happening?

    Thanks a lot for your support

  • Niels Odgaard 14 posts 155 karma points
    Sep 04, 2017 @ 10:35
    Niels Odgaard
    0

    Try adding ORDER BY to your sqlQuery

Please Sign in or register to post replies

Write your reply to:

Draft