kacor
asked on
IBExpress CommitRetaining
Hi Experts,
I develope an InterBase application with IBExpress components. On the DataModule there are TIBDatabase, TIBTransaction, TIBDataset components. On the Main form the DBNavigator has the procedure DBNavigatorClick which includes the following row:
if Button = nbPost then DM.IBTransaction1.CommitRe taining;
After each record I see the new rows but after closing the application the new data disappear. What is wrong?
wbr
Janos
I develope an InterBase application with IBExpress components. On the DataModule there are TIBDatabase, TIBTransaction, TIBDataset components. On the Main form the DBNavigator has the procedure DBNavigatorClick which includes the following row:
if Button = nbPost then DM.IBTransaction1.CommitRe
After each record I see the new rows but after closing the application the new data disappear. What is wrong?
wbr
Janos
ASKER
sorry for the mistake
if Button = nbPost then
begin
DM.DataSet1.Transaction.Co mmit;
DM.DataSet1.Active := True;
end;
if Button = nbPost then
begin
DM.DataSet1.Transaction.Co
DM.DataSet1.Active := True;
end;
ASKER
Delphi 6 + InterBase 6
How are you doing, Janos?!
Try use dataset.AfterPost Event instead dbnavigator events.
Again, I would not suggest use CommitRetaining/RolbackRet aining. Try don't use that construstion.
All the best,
Aleksey Emelyanov
Try use dataset.AfterPost Event instead dbnavigator events.
Again, I would not suggest use CommitRetaining/RolbackRet
All the best,
Aleksey Emelyanov
ASKER
The event "DBNavigator.OnClick" occurs when a button on the database navigator is clicked, after the action is executed. E.g. is the same as the "Dataset.AfterPost" Event I mean.
Otherwise I replaced the earlier script on the form with
procedure TDM.dsUjRaktariTetelAfterP ost(DataSe t: TDataSet);
begin
dsUjRaktariTetel.Transacti on.Commit;
dsUjRaktariTetel.Active := True;
end;
on the datamodule but no changes unfortunately.
Janos
Otherwise I replaced the earlier script on the form with
procedure TDM.dsUjRaktariTetelAfterP
begin
dsUjRaktariTetel.Transacti
dsUjRaktariTetel.Active := True;
end;
on the datamodule but no changes unfortunately.
Janos
try this:
procedure TDM.dsUjRaktariTetelBefore Post(DataS et: TDataSet);
begin
DataSet.Transaction := Transaction;
Transaction.DefaultAction := taCommit;
if not Transaction.InTransaction then
begin
DataSet.Database.DefaultTr ansaction := Transaction;
Transaction.StartTransacti on;
end;
end;
procedure TDM.dsUjRaktariTetelAfterP ost(DataSe t: TDataSet);
begin
try
if Transaction.InTransaction then
try
Transaction.Commit;
except
Transaction.Rollback;
end;
finally
DataSet.Active := False;
DataSet.Prepare;
DataSet.Open;
DataSet.Locate('ID', DataSet.FieldByName('ID'). AsString, []);
end;
end;
emil
procedure TDM.dsUjRaktariTetelBefore
begin
DataSet.Transaction := Transaction;
Transaction.DefaultAction := taCommit;
if not Transaction.InTransaction then
begin
DataSet.Database.DefaultTr
Transaction.StartTransacti
end;
end;
procedure TDM.dsUjRaktariTetelAfterP
begin
try
if Transaction.InTransaction then
try
Transaction.Commit;
except
Transaction.Rollback;
end;
finally
DataSet.Active := False;
DataSet.Prepare;
DataSet.Open;
DataSet.Locate('ID', DataSet.FieldByName('ID').
end;
end;
emil
sorry, please ignore:
DataSet.Locate('ID', DataSet.FieldByName('ID'). AsString, []);
emil
DataSet.Locate('ID', DataSet.FieldByName('ID').
emil
ASKER
Hi emil,
thank you for your help. Now I'll travel for 10 days and now I can't to test your proposition only after returning.
Sorry for this delay
with best regards
Janos
thank you for your help. Now I'll travel for 10 days and now I can't to test your proposition only after returning.
Sorry for this delay
with best regards
Janos
ASKER
Hi emil,
I am now back. I tried, but I've got the messages:
[Error] AdatModul.pas(84): Undeclared identifier: 'Transaction'
[Error] AdatModul.pas(85): Missing operator or semicolon
[Error] AdatModul.pas(86): 'THEN' expected but identifier 'InTransaction' found
[Error] AdatModul.pas(88): Undeclared identifier: 'Database'
[Error] AdatModul.pas(89): Missing operator or semicolon
[Error] AdatModul.pas(96): Undeclared identifier: 'Transaction'
[Error] AdatModul.pas(96): 'THEN' expected but identifier 'InTransaction' found
[Error] AdatModul.pas(98): Missing operator or semicolon
[Error] AdatModul.pas(100): Missing operator or semicolon
[Error] AdatModul.pas(104): Undeclared identifier: 'Prepare'
[Fatal Error] Browse.dpr(7): Could not compile used unit 'AdatModul.pas'
Have I to declare the variable Transaction and Database, or ... ? Waiting for your comment
wbr Janos
I am now back. I tried, but I've got the messages:
[Error] AdatModul.pas(84): Undeclared identifier: 'Transaction'
[Error] AdatModul.pas(85): Missing operator or semicolon
[Error] AdatModul.pas(86): 'THEN' expected but identifier 'InTransaction' found
[Error] AdatModul.pas(88): Undeclared identifier: 'Database'
[Error] AdatModul.pas(89): Missing operator or semicolon
[Error] AdatModul.pas(96): Undeclared identifier: 'Transaction'
[Error] AdatModul.pas(96): 'THEN' expected but identifier 'InTransaction' found
[Error] AdatModul.pas(98): Missing operator or semicolon
[Error] AdatModul.pas(100): Missing operator or semicolon
[Error] AdatModul.pas(104): Undeclared identifier: 'Prepare'
[Fatal Error] Browse.dpr(7): Could not compile used unit 'AdatModul.pas'
Have I to declare the variable Transaction and Database, or ... ? Waiting for your comment
wbr Janos
sorry about my mistakes:
procedure TDM.dsUjRaktariTetelBefore Post(DataS et: TDataSet);
begin
DataSet.Transaction := Transaction;
DataSet.Transaction.Defaul tAction := taCommit;
if not DataSet.Transaction.InTran saction then
begin
DataSet.Database.DefaultTr ansaction := Transaction;
DataSet.Transaction.StartT ransaction ;
end;
end;
procedure TDM.dsUjRaktariTetelAfterP ost(DataSe t: TDataSet);
begin
try
if DataSet.Transaction.InTran saction then
try
DataSet.Transaction.Commit ;
except
DataSet.Transaction.Rollba ck;
end;
finally
DataSet.Active := False;
DataSet.Prepare;
DataSet.Open;
end;
end;
emil
procedure TDM.dsUjRaktariTetelBefore
begin
DataSet.Transaction := Transaction;
DataSet.Transaction.Defaul
if not DataSet.Transaction.InTran
begin
DataSet.Database.DefaultTr
DataSet.Transaction.StartT
end;
end;
procedure TDM.dsUjRaktariTetelAfterP
begin
try
if DataSet.Transaction.InTran
try
DataSet.Transaction.Commit
except
DataSet.Transaction.Rollba
end;
finally
DataSet.Active := False;
DataSet.Prepare;
DataSet.Open;
end;
end;
emil
ASKER
Hi emil,
I use D6 and as I tried to compile the proposed source code I've got a lot of error again. Then I placed your code between brackets and I tried to repeat by hand what you proposed. And for DataSet is no valid property Transaction according to the code completion list only Tag and Translate. How can I round this ?
wbr Janos
I use D6 and as I tried to compile the proposed source code I've got a lot of error again. Then I placed your code between brackets and I tried to repeat by hand what you proposed. And for DataSet is no valid property Transaction according to the code completion list only Tag and Translate. How can I round this ?
wbr Janos
ASKER
And so InTransaction, Database andPrepare are also not valid properties for DataSet
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I so sorry, but I have big problems with my internet provider and I am online very rarely...
It is my mistake:
I am thinking about TIB components
but you need about dbExpress components
Sorry,
emil
I am thinking about TIB components
but you need about dbExpress components
Sorry,
emil
ASKER
Emil and Aleksey,
thank you both for supporting me. I can't finish what I begun because I have most urgent todo but after finishing I'll contnue.
I hope we will meet us in the future
with best regards
Janos
thank you both for supporting me. I can't finish what I begun because I have most urgent todo but after finishing I'll contnue.
I hope we will meet us in the future
with best regards
Janos
ASKER
if Button = nbPost then
begin
DM.DataSet1.Transaction.Co
DM.dsUjRaktariTetel.Active
end;
but in this case nothing changes, the new data don't appear
wbr
Janos