Private Sub ListCubes()
    Dim dsoServer As New DSO.Server
    Dim dsoDB As DSO.MDStore
    Dim dsoCube As DSO.MDStore    ' Create a connection to the Analysis server.
    dsoServer.Connect "LocalHost"    ' Step through the databases in the server object.
    For Each dsoDB In dsoServer.MDStores
        ' Print the name and description of the database
        Debug.Print "DATABASE: " & dsoDB.Name & " - " & _
        dsoDB.Description        ' Step through the cubes in the database object.
        If dsoDB.MDStores.Count = 0 Then
            Debug.Print "  Cube: None"
        Else
            For Each dsoCube In dsoDB.MDStores
                ' Print the name of the cube.
                Debug.Print "  Cube: " & dsoCube.Name                ' Check to see whether the cube is regular or virtual.
                If dsoCube.SubClassType = sbclsRegular Then
                   Debug.Print "       SubClassType: Regular"
                   Debug.Print "        SourceTable: " & _
                     dsoCube.SourceTable
                Else
                    Debug.Print "       SubClassType: Virtual"
                End If
             Next
        End If
    NextEnd Sub

解决方案 »

  1.   

    uses comobj,activex;
    var
      dsoServer,dsoDB,dsoCube:olevariant;
    begin
      dsoServer:=createoleobject('DSO.Server');
      dsoServer.connect.... 
    end;
      

  2.   

    关键是这个 For Each dsoDB In dsoServer.MDStores 在Delphi怎么解决???
      

  3.   

    Dim dsoServer As New DSO.Server
        Dim dsoDB As DSO.MDStore
        Dim dsoCube As DSO.MDStore
        dsoServer.Connect "LocalHost"
    这些都问题,都可以写
      

  4.   

    for i:=low(dsoServer.MDStores ) to high(dsoServer.MDStores ) do
    begin
      ...........
    end;
      

  5.   

    //下面是我写的一部分,但有错
    var dsoServer:Variant;
         dsoDB,dsoCube,dsotmp:Variant;
         dsoDatabase:Variant;
         i,n:integer;
    begin
       dsoServer:=CreateOleObject('DSO.Server');
       dsoDB:=CreateOleObject('DSO.MDStore');
       dsoCube:=CreateOleObject('DSO.MDStore');
       dsotmp:=CreateOleObject('DSO.MDStore');
       dsoDatabase := CreateOleObject('DSO.Database');
       dsoServer.Connect('localhost');
       if dsoServer.ClassType = clsServer then
       begin
          showmessage(dsoServer.Name);
       end;
       dsoDB:=dsoServer.MDStores;
      for i := 1 to dsoDB.count do
      begin
         dsoDatabase:=dsoServer.MDStores.item(i);
         showmessage(dsoDatabase.Name);
         dsoCube:=dsoDatabase.MDStores;
         for n:=1 to dsoCube.Count do
         begin
             dsotmp:=dsoCube.MDStores.item(i); //这里出错!!!!
             showmessage(dsotmp.name);
         end;
      end;
      dsoServer:=Unassigned;
      

  6.   

    for i := 0 to dsoDB.count-1 do
      begin
         dsoDatabase:=dsoServer.MDStores.item(i);
         showmessage(dsoDatabase.Name);
         dsoCube:=dsoDatabase.MDStores;
         for n:=0 to dsoCube.Count-1 do
         begin
             dsotmp:=dsoCube.MDStores.item(i); //这里出错!!!!
             showmessage(dsotmp.name);
         end;
      end;
      

  7.   

    上面出错的一句改成         dsotmp:=dsoCube.item(n); 
    就OK了!!!
      

  8.   

    代码的作用是连接上Analysis Server,取到有多少数据仓库及它的多维数据集
    Analysis Server安装目录Samples下有VB写的MDX 示例应用程序,想用Delphi来写,有没有写过,希望哪位能共享一下!急需
      

  9.   

    to outer2000(天外流星):
       但是你的写法 dsoCube.MDStores.item(n) 是错误的,当然这不是你的原因
      

  10.   

    hoho~~~流星出手了,就会帮到底的:)
      

  11.   

    还请各位看看
    http://expert.csdn.net/Expert/topic/1541/1541069.xml?temp=.734524
      

  12.   

    已经搞定,但提出数据后用Delphi自带的Decision Cube显示数据不完整,总会比实际的数据少N多条??为何?谁知道有没有更好用Decision Cube??????