说三道四技术文摘-感悟人生的经典句子
说三道四 > 文档快照

关于事务的问题!!在线等待!1

编辑:说三道四文库 发布时间:2018-06-23 02:14
HTML文档下载 WORD文档下载 PDF文档下载
有会的话可不可以说一下?
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, dbcgrids, ExtCtrls, DBCtrls, DB, ADODB, Grids, DBGrids,
  StdCtrls, Mask;

type
  TForm1 = class(TForm)
    ADOConnection1: TADOConnection;
    ADOQuery1: TADOQuery;
    DataSource1: TDataSource;
    ADOQuery2: TADOQuery;
    DBNavigator1: TDBNavigator;
    DBCtrlGrid1: TDBCtrlGrid;
    DataSource2: TDataSource;
    ADOQuery1SupplierID: TAutoIncField;
    ADOQuery1CompanyName: TWideStringField;
    ADOQuery1ContactName: TWideStringField;
    ADOQuery1ContactTitle: TWideStringField;
    ADOQuery1Address: TWideStringField;
    ADOQuery1City: TWideStringField;
    ADOQuery1Region: TWideStringField;
    ADOQuery1PostalCode: TWideStringField;
    ADOQuery1Country: TWideStringField;
    ADOQuery1Phone: TWideStringField;
    ADOQuery1Fax: TWideStringField;
    ADOQuery1HomePage: TMemoField;
    Label1: TLabel;
    DBEdit1: TDBEdit;
    Label2: TLabel;
    DBEdit2: TDBEdit;
    Label3: TLabel;
    DBEdit3: TDBEdit;
    DBNavigator2: TDBNavigator;
    DBGrid1: TDBGrid;
    ADOQuery3: TADOQuery;
    ADOQuery2CATEGORYNAME: TStringField;
    ADOQuery2ProductID: TAutoIncField;
    ADOQuery2ProductName: TWideStringField;
    ADOQuery2SupplierID: TIntegerField;
    ADOQuery2CategoryID: TIntegerField;
    ADOQuery2QuantityPerUnit: TWideStringField;
    ADOQuery2UnitPrice: TBCDField;
    ADOQuery2UnitsInStock: TSmallintField;
    ADOQuery2UnitsOnOrder: TSmallintField;
    ADOQuery2ReorderLevel: TSmallintField;
    ADOQuery2Discontinued: TBooleanField;
    procedure ADOQuery2CalcFields(DataSet: TDataSet);
    procedure ADOQuery1BeforePost(DataSet: TDataSet);
    procedure ADOQuery1AfterPost(DataSet: TDataSet);
    procedure ADOQuery1PostError(DataSet: TDataSet; E: EDatabaseError;
      var Action: TDataAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ADOQuery2CalcFields(DataSet: TDataSet);
begin
    try
      ADOQUery3.Parameters.ParamByName('categoryid').Value:=
        DataSet.FieldByName('categoryid').Value;
      ADOQuery3.Active:=True;
      DataSet.FieldByName('categoryname').Value:=
        ADOQuery3.FieldByName('categoryname').Value;
      finally
        ADOQUery3.Close;
     end;
end;

procedure TForm1.ADOQuery1BeforePost(DataSet: TDataSet);
begin
    ADOConnection1.BeginTrans;
end;

procedure TForm1.ADOQuery1AfterPost(DataSet: TDataSet);
begin
     ADOConnection1.CommitTrans;
end;

procedure TForm1.ADOQuery1PostError(DataSet: TDataSet; E: EDatabaseError;
  var Action: TDataAction);
begin
    ADOConnection1.RollbackTrans;
    Action:=daAbort;
end;

end.
ADO/mts/com+那本书里有讲!
备案号:鲁ICP备13029499号-2 说三道四 www.s3d4.cn 说三道四技术文摘