Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 959
  • Last Modified:

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.
 
0
datalabdd
Asked:
datalabdd
  • 7
  • 5
1 Solution
 
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 7
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now