BDE to SDAC - IndexDefs equivalent?

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
lcoelho
Posts: 47
Joined: Wed 13 Apr 2011 13:41

BDE to SDAC - IndexDefs equivalent?

Post by lcoelho » Fri 29 Apr 2011 13:33

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

AndreyZ

Post by AndreyZ » Fri 29 Apr 2011 14:34

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.

lcoelho
Posts: 47
Joined: Wed 13 Apr 2011 13:41

Post by lcoelho » Fri 29 Apr 2011 15:32

Thank you for your quick reply and solution. I will try that.

Post Reply