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
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
var
dsoServer,dsoDB,dsoCube:olevariant;
begin
dsoServer:=createoleobject('DSO.Server');
dsoServer.connect....
end;
Dim dsoDB As DSO.MDStore
Dim dsoCube As DSO.MDStore
dsoServer.Connect "LocalHost"
这些都问题,都可以写
begin
...........
end;
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;
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;
就OK了!!!
Analysis Server安装目录Samples下有VB写的MDX 示例应用程序,想用Delphi来写,有没有写过,希望哪位能共享一下!急需
但是你的写法 dsoCube.MDStores.item(n) 是错误的,当然这不是你的原因
http://expert.csdn.net/Expert/topic/1541/1541069.xml?temp=.734524