Page 1 of 1

Table pointer

Posted: Tue 15 May 2012 02:53
by marsheng
I have a query on a table. qryOne and tblOne. tblOne has a auto inc field called tblID.
qryOne fills a dbGrid. When I select a record in the dbGrid, how do I position the record pointer in the tblOne to the same record?

I can use Locate.tblID in Delphi but can I do the same with Sql?

Re: Table pointer

Posted: Tue 15 May 2012 08:41
by AndreyZ
Hello,

To locate a record in a dataset, you can use the FindKey or Locate methods. Here are code examples that demonstrate locating a record in a table using a record from a query:

Code: Select all

MyTable.FindKey([MyQuery.FieldByName('id').AsInteger]);

Code: Select all

MyTable.Locate('id', MyQuery.FieldByName('id').AsInteger, []);
For more information about this methods, please read the Delphi help.