Silverlight applications can run in two modes, In-Browser and Out-of-Browser. When running In-Browser (when you host it in a website in IIS), you cannot access a database directly. In-Browser Silverlight applications typically run with low-privilege.
You will need to create a WCF service to perform database queries and your Silverlight application will then have to communicate with the WCF service.
If you're using Silverlight 5 and your application is not public, perhaps consider enabling elevated trust:
http://msdn.microsoft.com/en-us/library/gg192793(v=vs.95).aspx[
^]