Home > Back-end >  Delphi ado transaction table update can only update a table
Delphi ado transaction table update can only update a table

Time:10-14

SQL server 2000 data, two tables, a basic information table have a save cost, another table is to save the cost detail, will meet every month there are several items of data only have updated the list, but there is no update the total cost of basic information table

F_Database. ADOCon. BeginTrans;


Qf:=FormatFloat (' 0.00 'F_Database. Qtb_StudentInfo. Fieldbyname (' fuel'). AsFloat + strtofloat (Edit2. Text));

F_Database. Qtb_StudentInfo. Close;
F_Database. Qtb_StudentInfo. SQL. The Clear;
F_Database. Qtb_StudentInfo. SQL. The Add (' update tb_StudentInfo set fuel='" + trim (qf) +' ' 'where student number=' "+ trim (Edit1. Text) +" '");
Try
F_database. Qtb_StudentInfo. ExecSQL;
Except,
On e: the exception do
The begin
F_database. ADOCon. RollbackTrans;
Application. Messagebox (' mistakes', 'prompt', mb_ok + mb_iconinformation);
exit;
End
end;

F_Database. Qtb_MoneyJf. Close;
F_Database. Qtb_MoneyJf. SQL. The Clear;
F_Database. Qtb_MoneyJf. SQL. Add (' insert into tb_MoneyJf (student number, name, capture expends project, payment amount, payment date, schooln, handlers, the payee, prepaid phone card number) values'
+ '("' + trim (Edit1. Text) + ' ' ', '
+ '"' + trim (label4. Caption) + ' ' ', '
+ '"' + trim (' fuel ') + ' ' ', '
+ '"' + trim (formatfloat (' 0.00 'StrToFloat (Edit2. Text))) +' ' ', '
+ '"' + trim (DateTimeToStr (Now ())) + ' ' ', '
+ '"' + trim (schooln) + ' ' ', '
+ '"' + trim (UserName) + ' ' ', '
+ '"' + trim (ComboBox2. Text) + ' ' ', '
+ '"' + trim (Edit4. Text) + ' ' '));
Try
F_database. Qtb_MoneyJf. ExecSQL;
Except,
On e: the exception do
The begin
F_database. ADOCon. RollbackTrans;
Application. Messagebox (' mistakes', 'prompt', mb_ok + mb_iconinformation);
exit;
End
end;

F_database.ADOCon.Com mitTrans;

CodePudding user response:

There is an error to rollback, oneself tracking,
  • Related