Page 1 of 1

BDE to SDAC - IndexDefs equivalent?

Posted: Fri 29 Apr 2011 13:33
by lcoelho
Hi,

I need to migrate the following code to SDAC equivalent. Unfortunately, I read that SDAC does not support IndexDefs. Is there a way to achieve the following in SDAC?

wwTable1.IndexDefs.Update;
wwTable1.FieldDefs.Update;

for I := 0 to wwTable1.IndexDefs.Count - 1 do
begin
if wwTable1.IndexDefs.Items.Fields = 'Field1' then
begin
......
end;
end;

Thank you

Posted: Fri 29 Apr 2011 14:34
by AndreyZ
Hello,

You can use the TMSMetadata component in the following way:

Code: Select all

MSMetadata.ObjectType := otIndexes;
MSMetadata.DatabaseName := 'database_name';
MSMetadata.TableName := 'table_name';
MSMetadata.Open;
while not MSMetadata.Eof do begin
  if MSMetadata.FieldByName('COLUMN_NAME').AsString = 'column_name' then begin
    //
  end;
  MSMetadata.Next;
end;
Note that MSMetadata returns indexes on more that one field in several records. You can see all fields available in the TMSMetaData component. For this, you should link it to the TDataSource and TDBGrid components. For more information, please read the SDAC documentation.

Posted: Fri 29 Apr 2011 15:32
by lcoelho
Thank you for your quick reply and solution. I will try that.