I tried submiting this as a comment, but the code did not display, lets try it as a solution. :)
When you run in visual studio, your app runs under the account you are logged onto your computer as. That is the account that will be used to access your database. For me, i am usually logged in as an adminstrator with full access to my databases. The same may be true for you.
Now, when you set things up in IIS, by default (unless you have done something else), the web app will run under a local account on that server. Which sounds like the case for you since the error message says: login failed for user SACS-COC\SPARE-PC$. That is the account that is trying to access your database, which probably doesn't have access.
What i normally do is in the web.config (where i keep connection strings), I pass a username and password for a SQL account that has access to the database. Like this:
<add name="MyConnectionString" connectionstring="Data Source=<ServerName>;Initial Catalog=<DB Name>;Persist Security Info=True;User ID=<UserName>;Password=<Password>">
providerName="System.Data.SqlClient" /></add>
This isn't the most secure since you will have plain text username and password in the web.config file. There are ways to encrypt and other ways to do this too. But, i hope this gives you enough info on WHY the error is happening and points you in a direction to find a solution that works for you.