Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread How to use MyTable.AppendRecord
Mon, Apr 9 2012 9:30 AMPermanent Link

Robert Rowlands

Hi.

I'm struggling with this method.

I have a memory table containing a few thousand contacts.  If another user adds a contact to the original table on the Server I need to load that record into memory if it is needed for a project.

I have a query to load the record from the Server.

I now want to copy the fields from the query to the memory table and AppendRecord seems to way to do this.

What is an array of TVarRec and how do I get the record in the query into this format?

Thanks.
Mon, Apr 9 2012 10:09 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Robert


AppendRecord & TVarRec are things I don't recognise, but if you have a query to extract the contact why not just use simple table methods?

inmemtable.insert;
inmentable.fieldbyname('contact').asstring := query.fieldbyname('contact').asstring;
....
....
inmemtable.post;
query.close;

Roy Lambert  [Team Elevate]
Mon, Apr 9 2012 11:25 AMPermanent Link

Raul

Team Elevate Team Elevate

> What is an array of TVarRec and how do I get the record in the query
into this format?

Appendrecord has to be able to accommodate variety of datatypes hence it
uses open array as input (the other common use for this is Format
statement). Internally delphi uses TVarRec for this but from your
perspective you should be able to do something like  this Frownssume first
2 fields are int and 3rd is string) mytable.AppendRec( [1,2,'abc'] );

Raul
Mon, Apr 9 2012 1:37 PMPermanent Link

Robert Rowlands

Roy.

I was trying to do something similar to that suggested by Raul but did not have the square brackets.

I've coded it as you suggested.

Thanks.
Image