1
votes

I'm using Delphi 7 and ms SQL server 2008. I have a DBGrid (actuaty a custom control called TEnhDBGrid, if you know it) and an ADO connection. I'm using a ADOQuery to populate my grid:

with dbMod.clientQuery do
begin
  sql.text:='select * from client order by id';
  open;
end;
clientGrid.Columns[0].visible:=false;
clientGrid.Columns[1].width:=110;
clientGrid.Columns[2].width:=170;
clientGrid.Columns[3].width:=100;
clientGrid.Columns[4].width:=100;

The field for the "client" table in the DB, that the query returns are: enter image description here

I want to select the row with a specific ID in the grid, and i can't seem to figure it out.

1

1 Answers

5
votes

You can do a locate in the TADOQuery. This will position the grid where ID is 5.

dbMod.clientQuery.Locate('id', 5, []);