title: Cannot initialize the data source object of Linked Server in published apps using IIS
body: <p>Trying to query a linked server with and without Openquery. The connections and queries work normally when executed from SSMS or when debugging any app in Visual Studio. Console apps that use the connection also work normally. However, once the web app is published the connection fails with an exception. </p>
  
  <blockquote>
    <p>Cannot initialize the data source object of OLE DB provider "MSDASQL" for >linked server "NetSuite".</p>
  </blockquote>
  
  <p>I've tried rebooting both the app and SQL servers. Also deleting the app's folder and republishing and converting to an app in IIS didn't resolve.</p>
  
  <p>The queries are really simple and working normally when using Management Studio or any non-IIS related app. Here is an example that is working there but not on published apps.</p>
  
  <pre><code>select * from openquery(NetSuite, 'select * from employees')
  </code></pre>
  
  <p>I've searched for hours and tried everything I can think of. Does anybody know why a linked server would stop working only in published .NET web apps using IIS specifically after an ODBC driver update? I would appreciate any help!</p>
  
  <p>UPDATE:</p>
  
  <p>For anybody who runs into this the solution ended up being really simple. When the app executes code it will be executing queries under the machine account of the IIS server. To resolve you have to give that machine account read/write permission to this folder:</p>
  
  <blockquote>
    <p>C:\Windows\ServiceProfiles\NetworkService\AppData\Local\Temp</p>
  </blockquote>
  
  <p>Thanks everyone for the suggestions!</p>