title: network-related or instance-specific error when accessing database from a windows service
body: <p>I want to perform some actions against a database from a custom windows service. The database is accessed through a reference to a Repository project. So, at one side i have the Service and at the other the Repository.</p>
  
  <p>The problem is that i get a SqlException saying "a network-related or instance-specific error occurred while establishing a connection" at the Windows Event Viewer log when starting the Service.</p>
  
  <p>The answers that i've readed already suggests that it could be due to permissions problems, but i'm running the service with the same user that i use to access the database (windows authentication) and both the Service and the Repository project has the same ConnectionString, which is as follows:</p>
  
  <pre><code>&lt;connectionStrings&gt;
  &lt;add name="ViewMediaDBEntities" connectionString="metadata=res://*/ViewMediaDBModel.csdl|res://*/ViewMediaDBModel.ssdl|res://*/ViewMediaDBModel.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=VIEWCAP\SQLEXPRESS12;initial catalog=ViewMediaDB;integrated security=True;multipleactiveresultsets=True;application name=EntityFramework&amp;quot;" providerName="System.Data.EntityClient" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>Any suggestions?</p>
  
  <p><strong>EDIT:
  (SOLUTION)</strong></p>
  
  <p>The problem has gone... It was just that the connection to the database was corrupted (for some reason that i don't know)... After rebooting the system everything started to work fine.</p>