Table pointer

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
marsheng
Posts: 62
Joined: Thu 10 May 2012 10:51

Table pointer

Post by marsheng » Tue 15 May 2012 02:53

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?

AndreyZ

Re: Table pointer

Post by AndreyZ » Tue 15 May 2012 08:41

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.

Post Reply