本文介绍了建立一个本地立方体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要为使用Excel的客户端构建本地.cub文件.
I need to build a local .cub file for my Excel-using clients.
我已经拼凑了一些VB代码,但失败了:
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
我已将此代码精简为上面的代码,并且在尝试运行它时得到了神秘的OLE DB error: OLE DB or ODBC error.
.
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.
推荐答案
您的连接字符串DSN属性似乎有误:
Your connection string DSN property seems wrong:
ConnDSN = "SOURCE_DSN=""DSN=TEST;UID=test;PWD=pass;"""
请注意引号.
我建议对代码进行少量更改,以使其更直观,更安全:
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 & """;"
这篇关于建立一个本地立方体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!