I sympathise completely and I had exactly the same problem at school. Forget about learning tables of articles for the time being, and think about pronouns in English: why is it ungrammatical to say "I gave she the pen" or "He is swimming with I"? Despite these phrases being ungrammatical, they can be understood. So in English there are the following pairs of pronouns:
- I, me
- you, you
- he, him
- she, her
- it, it
- we, us
- they, them
The first type are nominative and used as the subject of verbs. They correspond directly with ich, du, er, sie, es, wir etc. So far so easy. Unfortunately the second type doesn't correspond directly with the dative or accusative in German; the accusative and dative ceased to be separate cases in English several hundred years ago. There is still a grammatical distinction between the direct and indirect objects in English, they just aren't flagged morphologically.
If you're familiar with programming, verbs are like functions, they take arguments. Some verbs don't take any i.e. are intransitive ("I swam"). Most other verbs usually have one argument: the direct object: "I bit him". Some verbs have an additional, optional second argument: the indirect object. So, "I passed the ball" and "I passed her the ball" are both possible. The "ball" is the direct object, "her" is the indirect object.
In German, the direct object is always in the accusative case, while the indirect object is always in the dative case. Note how, from the final example, I can also say "I passed the ball to her", which gives some clue as to the function of the indirect object.
The final twist is that prepositions usually force a case. For example, a noun following zu will always be in the dative, and a noun following durch will always be accusative. This will come with practice.
If you're wondering what all this is for, the most commonly heard example is that "der Hund beißt den Mann" and "den Mann beißt der Hund" are understood to mean the same thing in German, because the subject is marked with a nominative article and the direct object is marked with an accusative article. "The dog bites the man" and "the man bites the dog" are very different in English; in other words, we mark the subject, direct object and indirect object by their position in the sentence and not by changing their articles.
Once you understand the principle, the rest is just (a lot of) practice, as the other answers suggest.