我需要为使用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 error: OLE DB or ODBC error.
。
上述任何帮助或以不同的方式提出建议我都会非常感激。
答案 0 :(得分:2)
您的连接字符串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 & """;"