下面程序是一个数据输入程序,为何每次输入后,显示两条纪录(但是打开数据库只有一条纪录)
unit Unit6;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DBCtrls, Buttons, Grids, DBGrids, ComCtrls, ToolWin,
Mask, ExtCtrls;type
Tform6 = class(TForm)
ToolBar1: TToolBar;
DBNavigator1: TDBNavigator;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label1: TLabel;
Label2: TLabel;
DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
DBGrid1: TDBGrid;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormActivate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
form6: Tform6;implementationuses unit2;
{$R *.dfm}
procedure Tform6.FormClose(Sender: TObject; var Action: TCloseAction);
begin
{ datamodule2.bumentable.CancelUpdates;
datamodule2.bumentable.Active:=false; }
action:=cafree;
datamodule2.bumentable.close;
end;
procedure Tform6.FormActivate(Sender: TObject);
begin
datamodule2.bumentable.Active:=true;
datamodule2.bumentable.CachedUpdates:=true;
end;procedure Tform6.BitBtn1Click(Sender: TObject);
begin
datamodule2.bumentable.applyupdates;
{datamodule2.bumentable.CachedUpdates:=false; }
end;procedure Tform6.BitBtn2Click(Sender: TObject);
begin
datamodule2.bumentable.cancelupdates;
datamodule2.bumentable.CachedUpdates:=false;
end;procedure Tform6.FormCreate(Sender: TObject);
begin
with datamodule2.bumentable do
begin
databasename:='laobao';
tablename:='bumen.db';
{ indexfieldnames:='bumenname'; }
end;
end;end.
unit Unit6;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DBCtrls, Buttons, Grids, DBGrids, ComCtrls, ToolWin,
Mask, ExtCtrls;type
Tform6 = class(TForm)
ToolBar1: TToolBar;
DBNavigator1: TDBNavigator;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label1: TLabel;
Label2: TLabel;
DBEdit1: TDBEdit;
DBEdit2: TDBEdit;
DBGrid1: TDBGrid;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormActivate(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
form6: Tform6;implementationuses unit2;
{$R *.dfm}
procedure Tform6.FormClose(Sender: TObject; var Action: TCloseAction);
begin
{ datamodule2.bumentable.CancelUpdates;
datamodule2.bumentable.Active:=false; }
action:=cafree;
datamodule2.bumentable.close;
end;
procedure Tform6.FormActivate(Sender: TObject);
begin
datamodule2.bumentable.Active:=true;
datamodule2.bumentable.CachedUpdates:=true;
end;procedure Tform6.BitBtn1Click(Sender: TObject);
begin
datamodule2.bumentable.applyupdates;
{datamodule2.bumentable.CachedUpdates:=false; }
end;procedure Tform6.BitBtn2Click(Sender: TObject);
begin
datamodule2.bumentable.cancelupdates;
datamodule2.bumentable.CachedUpdates:=false;
end;procedure Tform6.FormCreate(Sender: TObject);
begin
with datamodule2.bumentable do
begin
databasename:='laobao';
tablename:='bumen.db';
{ indexfieldnames:='bumenname'; }
end;
end;end.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货