No, you have to learn them - sorry.
But there are not soo many of them.
Dative: aus (from location), bei (at location or persom, i.e. 'bei ihm'), mit (with), nach (after - time, to - location, but usually used without article 'nach Hause'), von (from), zu (to)
Accusative: bis (till, until), durch (through), für (for), gegen (against), ohne (without), um (at - time)
both dative and accusative: an, auf, hinter, in, neben, über, unter, vor, zwischen
---> But don't ask me how to recognize when you use dative or accusative.
Hope, I could help you more.