Should I use First after using Open in Firedac?

Asked

Viewed 50 times

0

When I use Fdquery to perform a select that returns n records, I need to use the . First command after the . Open to make sure it stays on the first record?

Example:

QryAux3.Close;
QryAux3.SQL.Text := 'Select * from Produtos';
QryAux3.Open;
QryAux3.First; //Precisa desta linha?
  • For good practice yes... almost everyone does. If you’re asking if the open is already on first, I’m not sure, probably, but I don’t think you should assume that.

1 answer

1

It makes no sense to use the first, just perform any query and observe the property RecNo will always be on the first record, ie after the command Open the cursor will always be in the first record.

Even if using Order by ASC/DESC and this goes for any component in Delphi, so make sure to leave it with the default settings.

This is the same as:

vTeste := TStringList.Create;
vTeste.Clear;

Totally unnecessary.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.