Search code examples
advantage-database-server

How use AdsCopyTableStructure to create ttAdsCDX table


Using Advantage Server 9x, I am trying to create a copy of a DBF/CDX table structure using the following code:

table1.AdsCopyTableStructure(d.AdsConnectionTemp.connectPath+'table.dbf');

The table that is created is of the type ttAdsADT, even though the original table is ttAdsCDX.

I tried using AdsConvertTable on the resulting table, but it pops an exception complaining that the operation cannot be done on free tables.

Any way to do this?


Solution

  • I was not able to get this function to work, but came up with a work around by using the following code:

     t:=TAdsTable.create(nil);
     try
          t.AdsTableOptions.AdsFilterOptions:=RESPECT_WHEN_COUNTING;
          t.open;
          t.AdsSetAOF('keyval=-1'); // gives an empty result
          t.AdsCopyTable('c:\somewhere\emlt.dat');
          t.close;
     finally
          freeAndNil(t);
     end;