构建本地立方体

发布于 2024-07-18 08:50:46 字数 556 浏览 4 评论 0原文

我需要为使用 Excel 的客户端构建本地 .cub 文件。

我已经收集了一些 VB 代码,但它失败了:

ConnLocation = "LOCATION=C:\test.cub;"
ConnDSN = "SOURCE_DSN=DSN=TEST;UID=test;PWD=pass;"
ConnCreateCube = _
"CREATECUBE=CREATE CUBE [TestCube] (" & _
"DIMENSION [account_code]);"
Connection = CreateObject("ADODB.Connection")
Connection.Provider = "msolap"
Connection.ConnectionString = _
    ConnLocation & _
   ConnDSN & _
ConnCreateCube

我已将其精简为上面的代码,但当我尝试运行它时,收到一个神秘的“OLE DB 错误:OLE DB 或 ODBC 错误。”。

对于上述问题的任何帮助或以不同方式解决此问题的建议将不胜感激。

I need to build a local .cub file for my Excel-using clients.

I have scrounged together some VB code but it fails :

ConnLocation = "LOCATION=C:\test.cub;"
ConnDSN = "SOURCE_DSN=DSN=TEST;UID=test;PWD=pass;"
ConnCreateCube = _
"CREATECUBE=CREATE CUBE [TestCube] (" & _
"DIMENSION [account_code]);"
Connection = CreateObject("ADODB.Connection")
Connection.Provider = "msolap"
Connection.ConnectionString = _
    ConnLocation & _
   ConnDSN & _
ConnCreateCube

I have trimmed this down to the above code and am getting a mysterious OLE DB error: OLE DB or ODBC error." when I try to run it.

Any help on the above or suggestions on a different way to approach this would me much appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

玉环 2024-07-25 08:50:46

您的连接字符串 DSN 属性似乎错误:

ConnDSN = "SOURCE_DSN=""DSN=TEST;UID=test;PWD=pass;"""

请注意引号。

我建议对代码进行一些小的更改,以使其更加直观和故障安全:

ConnLoc = "C:\test.cub"
ConnDSN = "DSN=TEST;UID=test;PWD=pass"
ConnSQL = "CREATE CUBE [TestCube] (DIMENSION [account_code])"

Connection = CreateObject("ADODB.Connection")
Connection.Provider = "msolap"
Connection.ConnectionString = "LOCATION=""" & ConnLoc & """;" & _
                              "SOURCE_DSN=""" & ConnDSN & """;" & _
                              "CREATECUBE=""" & ConnSQL & """;"

Your connection string DSN property seems wrong:

ConnDSN = "SOURCE_DSN=""DSN=TEST;UID=test;PWD=pass;"""

Note the quotes.

I would recommend a small code change to make it more intuitive and fail-safe:

ConnLoc = "C:\test.cub"
ConnDSN = "DSN=TEST;UID=test;PWD=pass"
ConnSQL = "CREATE CUBE [TestCube] (DIMENSION [account_code])"

Connection = CreateObject("ADODB.Connection")
Connection.Provider = "msolap"
Connection.ConnectionString = "LOCATION=""" & ConnLoc & """;" & _
                              "SOURCE_DSN=""" & ConnDSN & """;" & _
                              "CREATECUBE=""" & ConnSQL & """;"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文