I don't know if you're using SQL Server as your backend, but the idea is to spit out the query string you're submitting and try running it somwhere outside your code. That usually points out syntax ...