Problema com ChangeCount do ClientDataSet

Delphi

11/01/2007

Olá,

Estou enfrentando um problema ao excluir, estou excluíndo um registro do Client com Delete e testo antes do ApplyUpdates se ChangeCount é maior que zero. Mas estou excluíndo e o ChangeCount volta zerado.

O que será???

valeu.


Edvilson.chaves

Edvilson.chaves

Curtidas 0

Respostas

Truck1n

Truck1n

11/01/2007

Boa tarde,

vc está usando assim ?

 if (ClientDataSet1.ChangeCount > 0) then 
    ClientDataSet1.ApplyUpdates(-1);


Description Check ChangeCount to determine how many modifications are pending for the dataset. ChangeCount increases when the data is edited. It is reset when updates are applied or merged and any differences are reconciled by the client dataset.


posta o código que você deleta o registro por favor!


Abraços!


GOSTEI 0
Edvilson.chaves

Edvilson.chaves

11/01/2007

if (not GetClient.Active) or (GetClient.RecordCount <= 0) then
raise EBusinessError.Create(´Não existem registros a excluir.´);

if pPedirConfirmacao then
if Controle_Interface.Mensagem(´Confirma a exclusão do registro selecionado?´, mtInformation, [mbNo, mbYes]) <> mrYes then
Abort;

if GetClient.State = dsBrowse then
GetClient.Delete;

if GetClient.Active and (GetClient.ChangeCount > 0) then
begin
if pAbrirTransacao then
AbrirTransacao(FTDExcluir);

Try
// ExcluirOutrasTabelas; //???

if (GetClient.ApplyUpdates(pMaxErros) > pMaxErros) and (pMaxErros <> -1) then
begin
GetClient.CancelUpdates;
if (FMensagemReconcile = ´´) then
raise EAbort.Create(cMsgErroBDUpdate)
else
raise EAbort.Create(FMensagemReconcile);
end;

if pAbrirTransacao then
GetSQLConnection.Commit(FTDExcluir);
except
if pAbrirTransacao then
GetSQLConnection.Rollback(FTDExcluir);
raise;
end;
end;


GOSTEI 0
Edvilson.chaves

Edvilson.chaves

11/01/2007

desculpem, encontrei o erro. Estava movimentando o cursor nos campos e exitem alguns tratamentos no evento OnExit.

Obrigado a todos.


GOSTEI 0
POSTAR