I'm attempting to run a stored procedure that processes an excel file for import from a Windows Service developed in C#. I can run the stored procedure directly in SQL Server Management Studio, but when running the stored procedure through the service I get the following error;
Ad hoc access to OLE DB provider 'Microsoft.ACE.OLEDB.12.0' has been denied. You must access this provider through a linked server.
Microsoft.ACE.OLEDB.12.0
is listed in Server Object\\Linked Servers\\Providers
, additionally, Disallow adhoc access
is unchecked in the Provider Options.
I don't know what else to try. Any thoughts? TIA
EDIT : added some service code
public ProcessFile(string fileName)
{
this.fileName = fileName;
fileToProcess = Properties.Settings.Default.importFilePath + "\\" + fileName;
log.Debug("fileToProcess: " + fileToProcess);
OpenExcelFile();
excelSheets = getSheetNames();
excelWorkSheet = (Excel.Worksheet)excelSheets.get_Item(2);
log.Debug("sheet Name: " + excelWorkSheet.Name);
connectToDb();
CloseExcelFile();
}
private void connectToDb()
{
int retVal = db.LoadSPVDataSheet(Properties.Settings.Default.importFilePath, this.fileName, excelWorkSheet.Name);
}
EDIT 2
I'm using SQL Server 2012 running on Windows Server 2012 R2
EDIT 3 I found the entry for AllowInProcess
, and the Disallow Adhoc entry wasn't there. It was located @:
HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WOW6462Node\Microsoft\Microsoft SQL Server\MSAS11.<ServerName>\Providers\MSOLAP
I'm going add the entry and report back.
EDIT 4
The service code is now connecting and processing correctly. I found another place where the DisallowAdHocAccess
registry key was missing.
HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\WOW6462Node\Microsoft\Microsoft SQL Server\MSSQL11.<ServerName>\Providers\Microsoft.ACE.OLEDB.12.0
I added the key there, and it worked.
Check out this connect item: https://connect.microsoft.com/SQLServer/feedback/details/257494/smss-does-not-handle-the-provider-option-disallowadhocaccess-correctly or read the detailes explained here: https://www.mssqltips.com/sqlservertip/4582/sql-server-ad-hoc-access-to-ole-db-provider-has-been-denied-error/ "We can disable "Disallow adhoc access" from the SSMS provider properties, but it removes the entry in the registry instead of changing the value to zero and we still get the ad hoc access to OLE DB provider has been denied error." So you should manually add the missing entry in registry and enter 0 in it
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.