Delete Field Bug

Discussion of open issues, suggestions and bugs regarding Virtual Data Access Components for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
m227
Posts: 59
Joined: Mon 06 Aug 2007 12:41

Delete Field Bug

Post by m227 » Fri 05 Feb 2010 12:45

Hello Friends.

How to delete field from VirtualTable in runtime?
All functions below:

Code: Select all

  with BA.FieldDefs do Delete( IndexOf('aktywne') );
  TVirtualTable(BA).DeleteField('aktywne');
  BA.FieldDefs.Find('aktywne').Free;
  BA.FieldDefs[BA.FieldDefs.IndexOf('aktywne')].Destroy;
seem to free values at most, leaving field in table.

any help?

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Mon 08 Feb 2010 08:38

You can use the following code:

Code: Select all

  VirtualTable1.Close;
  VirtualTable1.DeleteField('aktywne');
  VirtualTable1aktywne.DataSet := nil;
  VirtualTable1.Open;

m227
Posts: 59
Joined: Mon 06 Aug 2007 12:41

Post by m227 » Mon 08 Feb 2010 10:38

I am afraid it does not work in my case.
My VirtualTable was assigned from other VT:

Code: Select all

    BA := TVirtualTable.Create(Self);
    BA.Assign(vtBadanie);
So I have no names of fields like VirtualTable1aktywne to nullify its DataSet property.

And without this line it does not work again.

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 09 Feb 2010 08:40

Use FieldByName('aktywne')

m227
Posts: 59
Joined: Mon 06 Aug 2007 12:41

Post by m227 » Tue 09 Feb 2010 09:46

Thank you,

Now it works flawelessly. It suits me fine. Only question is if wouldn't it be better to use simple line as i.e. DeleteField, instead for four lines of code?
Of course I can make myself some function but nice have it made internally.

Thanks again.
Michal.

Post Reply