尝试在MS SQL Server上运行存储过程时拒绝访问

时间:2015-08-21 16:21:31

标签: sql-server stored-procedures oledb oledbdataadapter oledbexception

当我尝试运行存储过程时,我收到以下错误消息。

  

Msg 7399,Level 16,State 1,Procedure accountupdater,Line 10 OLE   链接服务器“(null)”的数据库提供程序“Microsoft.ACE.OLEDB.12.0”   报告错误。拒绝访问。 Msg 7350,Level 16,State 2,   过程accountupdater,第10行无法获取列信息   来自OLE DB提供程序“Microsoft.ACE.OLEDB.12.0”的链接服务器   “(空)”。

其他信息:之前它正在运行,但在安装MS Office后,它开始给出错误消息。我们卸载了MS Office并重新安装了“Microsoft Access数据库引擎2010”。仍然收到错误消息。

做了一些研究,发现我需要安装“Microsoft Access数据库引擎2010”。我做了,但仍然收到相同的错误消息。

ALTER PROCEDURE [dbo].[accountupdater]
AS
  DECLARE @accountNum numeric, @businessFEIN varchar(100), @stateID varchar(100), @dbaName varchar(100), @addressLine1 varchar(100), @addressLine2 varchar(100), @city varchar(100), @state varchar(100), @zip varchar(100), @businessName varchar(100)
  DECLARE accountCursor CURSOR FAST_FORWARD FOR
    SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
    'Text; HDR=YES; Database=D:\Innoprise\',
    'SELECT * FROM flagstaffAccountUpdate.csv') ors
  OPEN accountCursor

  --perform first fetch
  FETCH NEXT FROM accountCursor INTO @accountNum, @businessFEIN, @stateID, @dbaName, @addressLine1, @addressLine2, @city, @state, @zip, @businessName

  --check if there are more rows to fetch
  WHILE @@FETCH_STATUS = 0
  BEGIN  

  update BUSINESS SET FEIN=coalesce(@businessFEIN, FEIN), name=coalesce(@businessName, name) WHERE ID = (select business_id from VENDOR v where v.vendornumber=@accountNum);
  update DBA set name=coalesce(@dbaName, name) where id = (select primarydba_id from vendor v where v.vendorNumber=@accountNum);
  update VENDOR set stateId=coalesce(@stateID, stateID) where vendorNumber=@accountNum;
  update ADDRESS set addressLine1=coalesce(@addressLine1,addressLine1), ADDressline2=coalesce(@addressLine2,addressline2), 
  city=coalesce(@city,city), state=coalesce(@state,state), zipCode=coalesce(@zip,zipCode)
  where ID = (select v.address_ID from VENDOR v where v.vendorNumber = @accountNum);
  FETCH NEXT FROM accountCursor INTO @accountNum, @businessFEIN, @stateID, @dbaName, @addressLine1, @addressLine2, @city, @state, @zip, @businessName
END
  CLOSE accountCursor
  DEALLOCATE accountCursor

1 个答案:

答案 0 :(得分:0)

如果您已经安装了Microsoft Access数据库引擎2010,请执行以下查询并重新启动SQL Server Management Studio或SQL服务。 Refer here

USE [master] 
GO 
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1 
GO 
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1 
GO