I don't think flash will be able to query a database when it is a projector file (.exe).
I have been successful at sending variables from flash to a php script that retrieves data from mysql and formats a page in html so flash can then retrieve new variables, but it is quite clunky and slow.
If you however are interested in this type of interactivity, there is a great book called "Server-Side Flash" by Sanders and Winstanley, published by Hungry-Minds.