Transaction Processing

ADO supports transaction processing, and this is handled through the TADOConnection component. As an example, the code in Listing 9.3 is taken from our simple order entry application.

Listing 9.3. Transaction Processing with TADOConnection
procedure TMainForm.Button1Click(Sender: TObject); begin if TNewOrderForm.Execute then begin ADOConnection1.BeginTrans; try // First Create an Orders Record adodsOrders.Insert; adodsOrders.FieldByName('CustNo').Value := adodsCustomer.FieldByName('CustNo').Value; adodsOrders.FieldByName('EmpNo').Value := adodsEmployee.FieldByName('EmpNo').Value; adodsOrders.FieldByName('Date').Value := Date; ShowMessage(IntToStr(adodsOrders.FieldByName('OrderNo').AsInteger)); adodsOrders.Post; // Now ...

Get Borland® Delphi™ 6 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.