Field edited doesn't update after reopen the query

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
defferrari
Posts: 14
Joined: Wed 23 Mar 2011 17:09

Field edited doesn't update after reopen the query

Post by defferrari » Tue 02 Jul 2013 15:16

Hi, I'm having a weird problem. The routine doesn't work on user computer, but work fine in my computer accessing remotely the DB of the client.
I have a form with a grid that shows the records of the table CARTAO_VT_GENERICO, and that form have a button that open another form that allows edit one field of the selected record. Then, when the edit form is closed, the query of the first form is closed and opened to refresh the data and, after locate the record edited, is inserted a record in another table using the field edited as a foreign key. In that point, in the user computer, the value of the edited field is zero.

I'm using Delphi 7 with Unidac 4.6.11 using Direct connection. The user has a Oracle server version 9.2.0.4.0.

Follow the code I'm using:

Code: Select all

procedure TfrmCadCartaoGenerico.btAtribuiClick(Sender: TObject);
begin
Application.CreateForm(TfrmAltCartaoGenericoFuncionario, frmAltCartaoGenericoFuncionario);
try
  DM.Dados.StartTransaction;
  try
     frmAltCartaoGenericoFuncionario.Tag := 2;
     frmAltCartaoGenericoFuncionario.CodCartaoVTGenerico := QConsulta.FieldByName('CODCARTAO_VT_GENERICO').AsInteger;
     if frmAltCartaoGenericoFuncionario.ShowModal = mrOK then
        begin
        QConsulta.Close;
        QConsulta.Open;
        QConsulta.Locate('CODCARTAO_VT_GENERICO', frmAltCartaoGenericoFuncionario.CodCartaoVTGenerico, []);
       
        GeraEntrega();
        end;
     DM.Dados.Commit;
  except
     DM.Dados.Rollback;
     QConsulta.Refresh;
     raise;
  end;
finally
  FreeAndNil(frmAltCartaoGenericoFuncionario);
end;
end;

procedure TfrmCadCartaoGenerico.GeraEntrega;
var
   CodEntrega: Integer;
   Descricao: string;
begin
CodEntrega := BQEntregas.BuscaEntregaDisponivel(1, QConsulta.FieldByName('CODCLIENTE_ENTREGA').AsInteger);
if (CodEntrega = 0) then
   CodEntrega := BQEntregas.IncluiEntrega(1, QConsulta.FieldByName('CODCLIENTE_ENTREGA').AsInteger); // Here 'CODCLIENTE_ENTREGA' is zero in user computer, but right value in mine computer

Descricao := 'ENTREGA DE CARTÃO GENÉRICO Nº ' + QConsulta.FieldByName('NUMERO_CARTAO').AsString +
             ' PARA O FUNCIONÁRIO ' + QConsulta.FieldByName('NOME_FUNCIONARIO').AsString +
             ' (CPF: ' + QConsulta.FieldByName('CPF_FUNCIONARIO').AsString + ')';

BQEntregas.IncluiItemEntrega(CodEntrega, 7, QConsulta.FieldByName('CODCARTAO_VT_GENERICO').AsInteger, Descricao);
end;
Where 'CODCLIENTE_ENTREGA' is the field edited in frmAltCartaoGenericoFuncionario

defferrari
Posts: 14
Joined: Wed 23 Mar 2011 17:09

Re: Field edited doesn't update after reopen the query

Post by defferrari » Tue 02 Jul 2013 18:19

Sorry, you can forget this post. I already found the problem, it was my fault at all

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Field edited doesn't update after reopen the query

Post by AlexP » Wed 03 Jul 2013 07:20

Hello,

Glad to see that you solved the problem. If you have any other questions, feel free to contact us

Post Reply