Building a local cube

ⅰ亾dé卋堺 提交于 2019-12-11 09:07:46

问题


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.


回答1:


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 & """;"


来源:https://stackoverflow.com/questions/801377/building-a-local-cube

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!