How to add a field programatically to a TAdoTable in Delphi

后端 未结 6 772
无人及你
无人及你 2021-01-16 10:48

In my Delphi 2009 application I need to check if a field exists and if it doesn\'t add it during application execution.

I have figured out the test for the field,

6条回答
  •  独厮守ぢ
    2021-01-16 11:26

    If the table is part of a SQL Databse, once you detect that the field is missing you can add the field via SQL, then re-open the table.

    cmd := tAdoCommand.create;
    try
      cmd.Connection := AdoConnection1;
      cmd.CommandText := 'ALTER TABLE table ADD TEST nvarchar(30)';
      cmd.Execute;
    finally
      cmd.Free;
    end; 
    

提交回复
热议问题