Um duvida sobre pesquisa usando o findkey!!

Delphi

08/08/2003

O correto seria:

a) With Table1 do
begin
table1.first;
while not eof do
begin
if findkey([´XXXXXXX´]) then
........
end;
table1.next;
end;

OU

b) With Table1 do
begin
table1.first;
if findkey([´XXXXXXX´]) then
........

Preciso saber se o FindKey, procura do 1º ao ultimo registro, ou tenho
que fazer um laço While, registro a registro para procura-lo!!


Host

Host

Curtidas 0

Respostas

Andre0201

Andre0201

08/08/2003

Para utlizar o método FindKey( [] ) do dataset, vc não precisa utilizar nenhum laço while, o dataset deve estar indexado pelo campo a ser pesquisado.


GOSTEI 0
Atomix

Atomix

08/08/2003

Caro Alex,

para realizar uma busca (Não sensitível) em uma Tabela, utilizando-se do FindKey([]) basta que você defina o índice respectivo ao campo em que você deseja efetuar a procura. (ATENÇÃO: O ídice precisa ser definido na estruturação da Tabela)

Ex.:
Table1.IndexName := ´ID´;
Table1.Findkey([´150´]); //Localiza o registro, no o ID é igual a 150

:)


GOSTEI 0
POSTAR