German prepositions are categorised according to whether they take the dative or the accusative. There are a list of prepositions that take the dative (such as mit, nach, von), and a list of prepositions that take the accusative (such as bis, entlang and fuer). All you need to do is learn which prepositions trigger the accusative and which trigger the dative. You then need to remember that any nouns which follow those prepositions must take the appropriate case. However, there is also a category of prepositions that can take both the accusative and the dative depending on the circumstance. In this situation, you need to be able to examine the context of the sentence to determine which to use. As a general rule we can say that when movement is implied the accusative is used, and when movement is not implied we use the dative. For example, 'in' is a preposition which takes both the accusative and the dative. We would say 'Ich gehe in die Stadt' (I go to town), using the accusative because there is movement to a place. However we would say 'Ich bin in der Stadt' (I am in town), using the dative because we have not moved, we are indicating a fixed position.