The account that runs the application pool needs access to the database. Saying that: it depends how you have set it up.
First I would try to check if the connection works. You could use telnet Iin a command window or PoswerShell) to find out:
telnet servername port
A default instance would run on port 1433, but if you have setup a named instance you have to check the port number.
If no: check the firewall.
If the connection is working (empty screen in the command window), check the permissions of the application pool account. Start by adding the user to the db_owner role, but strengthen security by the advisories in this blog article.