If there are two forms 1) Main form 2) Sub Form

In the Main Form there is a button which leads to the sub Form
The Sub form has got some database connectivity in that..
Do i have to create the connection in the main form or is it fine if I create it in the sub Form cuz Im getting security exceptions.

Can someone please help me out??? I appreicate ur help in advance