Question

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.

Was it helpful?

Solution

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 & """;"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top