Post - no records in the table (sometimes)
Posted: Mon 14 May 2012 01:13
Hello everybody !!!
I have the same structure.
A loop that runs through a text file and have to write thousands of records in a table.
See this below using post.
======
tr.IsolationLevel := xilREADCOMMITTED;
dm.conexao.StartTransaction(tr);
while not eof(tTxt) do
begin
ReadLn(tTxt,sL);
dm1.cdsSld.Append;
dm1.cdsSldRef.AsString := copy(sL,01,5);
dm1.cdsSldName.AsString := copy(sL,06,30);
dm1.cdsSld.post;
end;
try
dm1.cdsSld.ApplyUpdates(0);
dm.conexao.Commit(tr);
except
dm1.cdsSld.CancelUpdates;
// dm.ConRep.Rollback(tr); The drive that I use the "Devart" when an error occurs
//transaction is closed, impeding the Rollback but this not the problem in focus now
end;
========
This structure above works well in many programs.
But in some, it gives problem, not writing on BD
Write only the last record, which is what happens immediately before the ApplyUpdates(0).
So I have to change the structure, as I show below, only that it is strange and a little slower!
========
tr.IsolationLevel := xilREADCOMMITTED;
dm.conexao.StartTransaction(tr);
while not eof(tTxt) do
begin
ReadLn(tTxt,sL);
dm1.cdsSld.Append;
dm1.cdsSldRef.AsString := copy(sL,01,5);
dm1.cdsSldName.AsString := copy(sL,06,30);
dm1.cdsSld.ApplyUpdates(0); // was->dm1.cdsSld.post;
end;
try
// was->dm1.cdsSld.ApplyUpdates(0);
dm.conexao.Commit(tr);
except
dm1.cdsSld.CancelUpdates;
// dm.ConRep.Rollback(tr);
end;
========
I've tried with the sets:
TSQLQuery or TSQLDataset + TDataSetProvider + TClientDataset,
I changing various settings such, in UpdateMode, providerFlags and other...
Can someone show me how to use only the first structure, that is, how make it always works.
Thaks !!
I have the same structure.
A loop that runs through a text file and have to write thousands of records in a table.
See this below using post.
======
tr.IsolationLevel := xilREADCOMMITTED;
dm.conexao.StartTransaction(tr);
while not eof(tTxt) do
begin
ReadLn(tTxt,sL);
dm1.cdsSld.Append;
dm1.cdsSldRef.AsString := copy(sL,01,5);
dm1.cdsSldName.AsString := copy(sL,06,30);
dm1.cdsSld.post;
end;
try
dm1.cdsSld.ApplyUpdates(0);
dm.conexao.Commit(tr);
except
dm1.cdsSld.CancelUpdates;
// dm.ConRep.Rollback(tr); The drive that I use the "Devart" when an error occurs
//transaction is closed, impeding the Rollback but this not the problem in focus now
end;
========
This structure above works well in many programs.
But in some, it gives problem, not writing on BD
Write only the last record, which is what happens immediately before the ApplyUpdates(0).
So I have to change the structure, as I show below, only that it is strange and a little slower!
========
tr.IsolationLevel := xilREADCOMMITTED;
dm.conexao.StartTransaction(tr);
while not eof(tTxt) do
begin
ReadLn(tTxt,sL);
dm1.cdsSld.Append;
dm1.cdsSldRef.AsString := copy(sL,01,5);
dm1.cdsSldName.AsString := copy(sL,06,30);
dm1.cdsSld.ApplyUpdates(0); // was->dm1.cdsSld.post;
end;
try
// was->dm1.cdsSld.ApplyUpdates(0);
dm.conexao.Commit(tr);
except
dm1.cdsSld.CancelUpdates;
// dm.ConRep.Rollback(tr);
end;
========
I've tried with the sets:
TSQLQuery or TSQLDataset + TDataSetProvider + TClientDataset,
I changing various settings such, in UpdateMode, providerFlags and other...
Can someone show me how to use only the first structure, that is, how make it always works.
Thaks !!