Board index » delphi » ttable doesn't recognise new table definition SQL Server

ttable doesn't recognise new table definition SQL Server

Hi

I'm fixing code that recreates a temporary table on each loop for a report
on SQL Server.  The table can have different field definitions each time.
The problem is that on attempting to do a table.open, it only has the
original fields definition.

I've tried clearing the fields and fielddefs.update to no avail.  how can I
get ti to recognize the definition has changed?

Can't use a query instead  as this is a lot of existing code.

 

Re:ttable doesn't recognise new table definition SQL Server


Quote
"pc" <p...@nowwhere.com> wrote in message news:3d58e2e9$1@dnews...
> Hi

> I'm fixing code that recreates a temporary table on each loop for a report

If you are freeing and then recreating this shouldn't be a problem e.g.

for x := 0 to 100 do begin
  TempTable              := TTable.Create(Application);
  TempTable.DatabaseName := Database1.DatabaseName;
  TempTable.TableName    := 'MyDBTable';
  TempTable.FieldDefs.Update;
  TempTable.Open;

  { do some stuff here }

  TempTable.Close;
  TempTable.Free;
end;

Hope that helps

Barney;

Other Threads