I learned in Tae Kim's Grammar Guide that だ cannot be used when asking a question. But in the book Japanese Sentence Patterns for Effective Communication by Taeko Kamiya, I found several example sentences that used だ in a question. I also have seen it being used this way in anime.
I'm guessing there is some type of exception to all of this? Anyways, I hope someone can shed some light on the subject for me. :)
== EDIT ==
Here is an example from the aforementioned book:
どうしてゆうべ来なかったんだ? (Why didn't you come last night?)
And here is an example from the title of the 249th episode of the show Dragon Ball Z:
悟飯はどこだ!? (Where's Gohan!?)