首页 > 解决方案 > 动态构建多维数据集连接

问题描述

我在 Excel 中有一个数据透视表,我可以通过使用连接属性打开 Excel 来访问和刷新它 -在此处输入图像描述

我在这个 Excel 的宏模块中使用了确切的属性 -

Sub UpdateQueryConnectionString()
  Dim cn As WorkbookConnection
  Dim oledbCn As OLEDBConnection
  Set cn = ThisWorkbook.Connections("http___xxxxx_olap_msmdpump.dll xxxx All xxxx")
  Set oledbCn = cn.OLEDBConnection
  oledbCn.CommandType = xlCmdCube
  oledbCn.CommandText = "All xxxx"
  oledbCn.Connection = "Provider = MSOLAP.8; Persist Security Info = True; User ID = xxxx; Password = xxxxx; Data Source = https://xxxxx/msmdpump.dll;Update Isolation Level=2;Initial Catalog=xxxxMAIN"
End Sub

错误“运行时错误'1004':应用程序定义的或对象定义的错误。” 发生在 oledbCn.Connection 中。

什么可能导致这种情况以及如何获得更多调试信息?

提前感谢您的帮助!

标签: excelvbadatabase-connectionolap-cube

解决方案


发现了问题。“OLEDB;” 在“Provider = MSOLAP.8;”之前需要。

oledbCn.Connection = "OLEDB;Provider = MSOLAP.8; Persist Security Info = True; User ID = xxxx; Password = xxxxx; Data Source = https://xxxxx/msmdpump.dll;Update Isolation Level=2;Initial Catalog=xxxxMAIN"

推荐阅读