Attached Tables

Home Forums kbmMemTable Attached Tables

Viewing 2 reply threads
  • Author
    Posts
    • #54744
      teamnavigator
      Participant

      I’m trying to understand attached tables.
      I have two attached tables which I’m using to give me the equivalent of two cursors on one set of data  e.g

      FThreadTable.AttachedTo := FCurrentTable;

      both tables have the properties
      AttachedAutoRefresh := True;
      AttachMaxCount := 1;

      It seems if I update a record in FCurrentTable, then FThreadTable sees those changes, but if I update a record in FThreadTable then those changes don’t synchronise back to FCurrentTable.
      So my questions are firstly, should this work i.e is it expected that the synchronisation is bi-directional ?
      If it should work, then could there be another property that might stop it working or do I need to call a method to push the changes ?

      Cheers

      David

    • #54745
      kimbomadsen
      Keymaster

      Hi,

      Yes it should autorefresh regardless on which table the change is made. However remember that you may have different index definitions on the two tables.

      I’ve just verified that it is working:

      Create a new VCL project.
      Add two TDataSource to the form.
      Add two TDBGrid to the form.
      Link each TDBGrid instances DataSource property to a unique TDataSource.
      Add a TButton. In its event handler write this code:

      FMT1:=TkbmMemTable.Create(nil);
      FMT1.FieldDefs.Add('fld1',ftInteger);
      FMT1.FieldDefs.Add('fld2',ftString,30);
      FMT1.CreateTable;
      
      FMT2:=TkbmMemTable.Create(nil);
      FMT2.AttachedTo:=FMT1;
      
      DataSource1.DataSet:=FMT1;
      DataSource2.DataSet:=FMT2;
      
      FMT1.Open;
      FMT2.Open;
      

      You will see that changing a record in one will update in the other.

    • #54746
      teamnavigator
      Participant

      Many thanks.

      That works perfectly. Now I need to work out why it doesn’t seem to work in my code !!

Viewing 2 reply threads
  • You must be logged in to reply to this topic.