www.german-grammar.deYou first of all need to understand the role that the word plays in the sentence -- subject, direct object, indirect object etc. In addition, there are several prepositions in German after which you must use a certain case. For example, after the word "mit", you must use the Dativ. Ex. Mit mir, dir, ihm (with me, you, him)
You can search for prepositions that use the akkusativ, dativ, genitiv. There are some that use both depending on the context. "In" is a good example. If movement from one place to another is involved, the akk is used after in. Ex. Ich gehe in die Schule. If in is used to describe the location of something that is stationary, the dat is used. Ex. Die Kinder sind in der Schule.
What is your native language? I learned German grammar pretty thoroughly at school before living in Germany for 3 months. Because I already understood the grammar, I could hear what I'd learned being used. To learn German as an adult is difficult unless you take some time to learn the grammar.
www.german-grammar.de Looks like a pretty good website for learning German grammar. Let me know if you found any of this useful.