Board index » delphi » Is there a way to use SetKey in TQuery?

Is there a way to use SetKey in TQuery?

Hi!
Is there a way to use SetKey in TQuery?
I have to switch field ( Ordning and Gruppnr) in two records.
The Query is already filtered so I cannot change it.
My code example that DO NOT WORK!

     With wwQueryFraga do begin
        ordn1:=FieldByName('Ordning').AsInteger;
        ordn1:=FieldByName('FragaIDnr').AsInteger;
        ordn1:=FieldByName('Gruppnr').AsInteger;
        DisableControls;
        Prior;
        if (not bof) then begin
                ordn2:=FieldByName('Ordning').AsInteger;
                ordn2:=FieldByName('FragaIDnr').AsInteger;
                ordn2:=FieldByName('Gruppnr').AsInteger;
                Edit;
                FieldByName('Ordning').AsInteger:=ordn1;
                FieldByName('Gruppnr').AsInteger:=ordn1;
                Post;
                SetKey;
                FieldByName('FragaIDnr').AsInteger:= ordn1;
                EditKey;
                FieldByName('Ordning').AsInteger:=ordn2;
                FieldByName('Gruppnr').AsInteger:=ordn2;
                Post;
         end;
         EnableControls;
  end;

  /Sargasso

Sent via Deja.com http://www.deja.com/
Before you buy.

 

Re:Is there a way to use SetKey in TQuery?


No. SetKey, FindKey, etc. all use the active index. There are no indices on
a query result set so you have three choices.
1) Rerun the query with a different WHERE clause.
2) Use TQuery.Locate.
3) Use a filter.

Bill
--

Bill Todd - TeamB
(TeamB cannot respond to questions received via email)

Other Threads