Walter,

- Para verificar se determinado campo existe na tabela basta conectar na 
mesma e usar as propriedades find e fieldlist para isto.


function Find (const Name: string): TField; reintroduce;
Returns a field component given the field name.

Description

Call Find to determine if a specified field component is referenced in 
the TFieldList object. FieldName is the name of the field for which to 
search. If Find finds a field with a matching name, it returns the 
TField component for the specified field. Otherwise it returns nil 
(Delphi) or NULL (C++).

Note:    Find differs from the FieldByName method only when the named 
field is not in the list. When the field is not found, Find returns nil 
(Delphi) or NULL (C++), while FieldByName raises an exception.


- Para alterar a estrutura:

  { Altera a esturutura }
   with MinhaTabela do
   try
     Close;
     with FieldDefs do
     begin
        Add('CAMPO1',ftString,15);
        Add('CAMPO2',ftFloat);
     end;
     CreateDataSet;
     Open;
   except
     Close;
     ShowMessage('Erro ao Alterar Tabela');
   end;

Sucesso !!

Moacir


Walter Chagas (Bol) escreveu:
> Pessoal,
>
> Me surgiu uma saia justa daquelas aqui no serviço.
>
> Temos um sistema que usa algumas tabelas dbase (.dbf) em alguns casos. O 
> problema é que este sistema pertence a uma regional e o funcionario que o fez 
> já picou a mula daqui da telemont a tempos e agora ele vai precisar de umas 
> adaptações mas por enquanto não vai dar pra trocar o banco por um SGBD pois o 
> sistema é altamente usado em alguns processos aqui e não pode parar.
>
> O que eu vou precisar é saber como eu insiro novos campos em uma tabela DBF 
> em tempo de execução e também como saber se o campo na tabela existe ou não. 
> O sistema usa como acesso a dados o BDE porém a manipulação dos dados na 
> tabela é toda via ClientDataset.
>
> Se alguem puder me dar uma luz nisto daí eu agradeço, até porque, o tempo pra 
> fazer isto é pra lá de curto. É negócio pra antes de ontem.
>
>
> []s
>
>
>
> Walter Alves Chagas Junior
> Belo Horizonte - MG - Brazil
> wchag...@bol.com.br
> http://www.geocities.com/SiliconValley/Bay/1058
> http://delphitocorporerm.blogspot.com/
> MSN: whitesock...@hotmail.com
> SKYPE: WalterChagasJr
>
>
> ------------------------------------
>
>   

Responder a