ADO MD (OLAP) - CubeDefs - how to get cube data and properties?

Hi!
Ive installed MDAC components to gain access to olap cubes(with D6). Im using the following code to do that:

procedure TForm1.CubeList(DataSource: WideString);
var I : Integer;
     DS         : WideString;
     Catalog1   : ICatalog;
     CubeDef1   : CubeDef;

begin
   Catalog1:=CreateComObject(StringToGUID('ADOMD.Catalog')) as ICatalog;
   Catalog1.Set_ActiveConnection(OleVariant(DS));
   if Catalog1.CubeDefs.Count > 0 then
   begin
       for i := 0 to Catalog1.CubeDefs.Count-1 do
       begin
            CubeDef1:= Catalog1.CubeDefs[i] as CubeDef; // it fails here
            TreeView1.Items.AddChild(nil, CubeDef1.Name);
      end;
   end;
end;

Ive searched the google up and down and couldnt find a solution to this problem. I keep getting  following error: [Error] Unit1.pas(57): Class does not have a default property.  So my question is how to access cubes propeties and data? With code plz.
btw: Funny thing is that Catalog1.CubeDefs.Count returns the right number of cubes.
 
datalabddAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lee_NoverCommented:
just do : Catalog1.CubeDefs.Items[i]
the compiler error was a big clue .. don't you think ?
also TheSource and CodeInsight are your friends :)
0
Lee_NoverCommented:
you can also be more specific (and more optimized code) and do:
CoCreateInstance(CLASS_Catalog, nil, CLSCTX_INPROC_SERVER or
     CLSCTX_LOCAL_SERVER, IID_ICatalog, Catalog1);

I prefer creating com objects like that
0
datalabddAuthor Commented:
I tried every thing:
1.Catalog1.CubeDefs.Item[i]
2.Catalog1.CubeDefs.Items[i]
3.Catalog1.CubeDefs[i]
Nothing works.
In cases 1. and 2. i get [Error] Unit1.pas(57): Undeclared identifier: 'Item/Items'.
In case 3. i get [Error] Unit1.pas(57): Class does not have a default property.
It if  go trough the source of ADOmd_tlb.pas CubeDefs is declared like this:

CubeDefs = interface(MD_Collection)
    ['{2281375D-8BD3-11D0-B4EF-00A0C9138CA4}']
    function Get_Item(Index: OleVariant): CubeDef25; safecall;
    property Item[Index: OleVariant]: CubeDef25 read Get_Item; default;
end;
So it should clearly work with your code. But somehow it does not.
If i put my cursor at the end of the code and then the drop down menu is displayed, there are only few options available (none of them being Items). So there is probably something wrong with my system. I have  ADOMD_tlb in my uses class but still it doesnt work.
Thx 4 any help.

0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Lee_NoverCommented:
just some posibilities using :
var
  cat: icatalog;
  cd: CubeDef;
begin
  cd:=cat.CubeDefs[0];
  cd._Release;
  cat.CubeDefs.Item[0]._Release;
  cat.CubeDefs[0]._Release;


compiles just fine
Delphi7 and imported ADO 2.8
also Delphi6 was the buggiest delphi ever ..

try reimporting the unit and check the library paths if there's a unit with a definition of CubeDefs that's different
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
datalabddAuthor Commented:
Ive tried every thing. I just doesnt work. Instaled MDAC on different computer. But same error. Looks like im getting nowhere with this. Ive searched the web for a solution and found this:
...
Since ADO MD support in Delphi 5 was not implemented at the components level. We need to use the type library to access ADO MD objects. This type library resides in msadomd.dll file. To do so, choose the Project | Import Type Library command from the main menu and in the Import Type Library  dialog box select Microsoft Microsoft ActiveX Data Objects (Multi-dimensional) 1.0 Library.

If you have already imported ADOX type library, you need to avoid conflicts with already declared Delphi TCatalog class. In this case, just rename TCatalog into TADOMDCatalog. It is also better to uncheck the Generate Component Wrapper checkbox because we need only to create a *.pas file to access ADO MD objects. Then press the Create Unit button.
...

But this doesent solve my problem.
Ill give u the points since im sure that what u wrote is right.
0
Lee_NoverCommented:
have you checked for any conflicting units .. you might have a dcu lying around that has a bad declaration of CubeDefs
following the link to CubeDefs would still take you to the right source file while linking a wrong dcu
0
datalabddAuthor Commented:
Hmmm ... i wouldnt know how to find this other declaration? I usualy just click the command or an object while holding down shift key and delphi takes me to the right file.  Is there any way to find double delarations?
0
Lee_NoverCommented:
that's for sources in the search path .. you can have a dcu in the library path and that's what will be compiled
just do a search for the dcu file
0
datalabddAuthor Commented:
I have searched for adomd_tlb.dcu and only found one file.
I dont see how i could find out if there is another unit that has CubeDefs defined in it.
0
Lee_NoverCommented:
search in files *.pas;*.dcu for text CubeDefs ...
0
datalabddAuthor Commented:
Ive searched the whole disk and only found 2 files that have cubedefs in them: adomd_tlb.pas and adomd_tlb.dcu. I performed the same search on another computer and the result was the same.
0
Lee_NoverCommented:
the interface that you wrote should work with any method I wrote (in the accepted answer)
I have no idea why you would get those compiler errors ... blame Delphi6 I guess
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.