Well, first of all i want to say → you perhaps should not mix dataset with wixDataQueries → this type of mixing → in most cases do not have a happy-end.
However → Check your permissions of your DB. For testing do → DOWNGRADE your DB-PERMISSIONS to → 0 ← (all permissions).
Then try it again. The difference between PREVIEW and PUBLIC is that in PREVIEW-MODE you have all PERMISSIONS to ACCESS a → DATABASE.
In PUBLISHED-MODE, the PERMISSIONS will be the same, like you did in your DB-PERMISSION-SETUP.
Surely a PERMISSION-PROBLEM.