Delete Field Bug

Delete Field Bug

Postby 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?
m227
 
Posts: 55
Joined: Mon 06 Aug 2007 12:41

Postby 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;
Plash
Devart Team
 
Posts: 2844
Joined: Wed 10 May 2006 07:09

Postby 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.
m227
 
Posts: 55
Joined: Mon 06 Aug 2007 12:41

Postby Plash » Tue 09 Feb 2010 08:40

Use FieldByName('aktywne')
Plash
Devart Team
 
Posts: 2844
Joined: Wed 10 May 2006 07:09

Postby 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.
m227
 
Posts: 55
Joined: Mon 06 Aug 2007 12:41


Return to VirtualDAC