title: Windows service and MS Access on UNC
body: <p>I am trying to get my Windows service to connect to an MS Acces database that is located on a UNC </p>
  
  <pre><code>private static void InsertData(string sql)
      {
          System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection();
  
          conn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;" +
                                  @"Data source=\\svr\Users\XXXX\XXXXX\db.accdb";
  
  
          try
          {
              conn.Open();
              OleDbCommand cmd = new OleDbCommand(sql, conn);
              cmd.ExecuteNonQuery();
  
              WriteToFile("Data saved successfuly...!");
          }
          catch (Exception ex)
          {
            WriteToFile("Failed due to: " + ex.Message);
          }
          finally
          {
              conn.Close();
          }
      }
  </code></pre>
  
  <p>This is the error I get
  "The Microsoft Access database engine cannot open or write to the file '\svr\Users\XXXX\XXXXX\db.accdb'. It is already opened exclusively by another user, or you need permission to view and write its data."</p>
  
  <p>The permissions are set to domain users, read, write and modify etc. The database is not open by anyone.</p>
  
  <p>I have tried the exact code in a console app and it works fine.
  Any ideas?</p>