Problem nested while i have problem with my code. it can't update from command lazarus / 16-Databases ---------------------------------------------------------------------- toem1234 · 2015-02-01 17:33 Problem  nested while  i have problem with my code. it can't update from command OR  where? example nested while.   Thank you Code: [Select]procedure TForm6.Update_Select_Income; begin    while not Select_Income.EOF do     begin       while not query.EOF do       begin         if ((Select_Income.FieldByName('income_category').AsString) = (query.FieldByName('income_category_name').AsString))  then         begin            Update_Income.Params.ParamValues['income_order']:= Select_Income.FieldByName('income_order').AsString;            Update_Income.Params.ParamValues['income_category']:= query.FieldByName('income_category_id').AsString;            Update_Income.ExecSQL;            Update_Income.Close;         end;         query.Next;       end;       Select_Income.Next;     end;    ShowMessage('Success!'); end; ---------------------------------------------------------------------- balazsszekely · 2015-02-01 17:55 Code: [Select]procedure TForm6.Update_Select_Income; begin    Select_Income.First; //make sure, it's the first record    while not Select_Income.EOF do     begin       query.First;  //make sure, it's the first record       while not query.EOF do       begin         if ((Select_Income.FieldByName('income_category').AsString) = (query.FieldByName('income_category_name').AsString))  then         begin            Update_Income.Close;            Update_Income.Params.BeginUpdate;            Update_Income.Params.ParamValues['income_order']:= Select_Income.FieldByName('income_order').AsString;            Update_Income.Params.ParamValues['income_category']:= query.FieldByName('income_category_id').AsString;            Update_Income.Params.EndUpdate;            Update_Income.ExecSQL;                  end;         query.Next;       end;       Select_Income.Next;     end;     Tansaction.CommitRetaining; //you need a transaction, to commit the changes    ShowMessage('Success!'); end;  If the params are correct this should work! Any exception raised? ShowMessage is displayed? ---------------------------------------------------------------------- toem1234 · 2015-02-01 18:21 i tested. it working Thank so much Code: [Select]procedure TForm6.Update_Select_Income; begin   Select_Income.First; //make sure, it's the first record   while not Select_Income.EOF do    begin      query.First;  //make sure, it's the first record      while not query.EOF do      begin        if ((Select_Income.FieldByName('income_category').AsString) = (query.FieldByName('income_category_name').AsString))  then        begin           Update_Income.Close;           Update_Income.Params.BeginUpdate;           Update_Income.Params.ParamValues['income_order']:= Select_Income.FieldByName('income_order').AsString;           Update_Income.Params.ParamValues['income_category']:= query.FieldByName('income_category_id').AsString;           Update_Income.Params.EndUpdate;           Update_Income.ExecSQL;        end;        query.Next;      end;      Select_Income.Next;    end;    Select_Income.CommitUpdates;   //.CommitRetaining; //you need a transaction, to commit the changes   ShowMessage('Success!'); end;