Excel连接错误:抛出了“Microsoft.Office.BackEnd.ExcelException”

时间:2016-07-15 14:40:09

标签: sql sql-server excel excel-vba powerpivot vba

我试图通过excel工作簿连接调用SQL Server存储过程。存储过程完美无缺 - 但是,当尝试通过excel刷新连接时,我收到以下错误消息:

"Run-time error '1004':

We couldn't refresh the connection 'CONNECTION'. Here's the  
error message we got:

Exception of type 
'Microsoft.Office.PowerPivot.Backend.ExcelException' was thrown."

我已尝试过所有内容 - NOCOUNT在此过程中设置为on。

编辑:

以下存储过程:

ALTER PROCEDURE [dbo].[spMSACount]
(
@merchIds_1     varchar(8000)
,@merchIds_2    varchar(8000)
,@msastring_1   varchar(8000)
,@msastring_2   varchar(8000)
)
AS



DECLARE @sqlText_1      varchar(300)
DECLARE @sqlText_2      varchar(100)
DECLARE @sqlText_3      varchar(100)

SET NOCOUNT ON

--Create Temp Table
SET @sqlText_1 =
' 
SET NOCOUNT ON

CREATE TABLE #temp
(
Merchant_ID int
)
INSERT INTO #temp VALUES'


--First portion Select Query
SET @sqlText_2 = 
'
SET NOCOUNT ON

 SELECT MerchantName 
        ,Category
        ,
'

--End portion Select Query
SET @sqlText_3 = 
' 
 FROM vwMerchantMSACount 
 WHERE Merchant_ID IN (
                        SELECT *
                        FROM #temp)

'





--EXECUTE CONCATENATED CODE
EXEC(@sqlText_1 + @merchIds_1 + @merchIds_2 + @sqlText_2 + @msastring_1 + @msastring_2 + @sqlText_3)

编辑: 下面的连接字符串:

Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=MerchantMaster;Data Source=TMXXX;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=TDXX;Use Encryption for Data=False;Tag with column collation when possible=False

0 个答案:

没有答案