Q&A

  • Table1.Append 에 대해서 좀 알려주세요
TTable 과 DBEdit를 이용해서 DB에 데이터를 추가 시킬려고 합니다.

그런데 추가는 안되고 업데이트가 되는데 이유가 뭔지 좀 알려주세요

Append 메소드를 사용했는데 안되네요

전체소스도 같이 올렸습니다. 설명 부탁드립니다.



추가 소스부분은

procedure TForm1.BitBtn1Click(Sender: TObject);

begin

if BitBtn1.Caption = '추가(&A)' then

begin

DB_Insert := '가능';

BitBtn1.Caption := '취소(&C)';

BitBtn2.Enabled := False;

Table1.Append;

end

else

begin

DB_Insert := '불가능';

BitBtn1.Caption := '추가 (&A)';

BitBtn2.Enabled := True;

Table1.Cancel;

end;

DBEdit2.SetFocus;

end;

여기까지 입니다.





unit Unit1;



interface



uses

Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,

ExtCtrls, DBCtrls, StdCtrls, Buttons, Mask, Db, DBTables;



type

TForm1 = class(TForm)

DataSource1: TDataSource;

Table1: TTable;

DBEdit2: TDBEdit;

DBEdit3: TDBEdit;

DBEdit4: TDBEdit;

DBEdit5: TDBEdit;

DBEdit6: TDBEdit;

Label2: TLabel;

Label3: TLabel;

Label4: TLabel;

Label5: TLabel;

Label6: TLabel;

BitBtn1: TBitBtn;

BitBtn2: TBitBtn;

BitBtn3: TBitBtn;

BitBtn4: TBitBtn;

DBNavigator1: TDBNavigator;

DBEdit7: TDBEdit;

DBEdit8: TDBEdit;

DBEdit9: TDBEdit;

Label7: TLabel;

Label8: TLabel;

Label9: TLabel;

DBEdit10: TDBEdit;

Label10: TLabel;

DBEdit11: TDBEdit;

Label11: TLabel;

DBEdit12: TDBEdit;

Label12: TLabel;

procedure FormCreate(Sender: TObject);

procedure BitBtn1Click(Sender: TObject);

procedure BitBtn3Click(Sender: TObject);



private

{ Private declarations }

DB_Insert : String;

public

{ Public declarations }

end;



var

Form1: TForm1;



implementation



{$R *.DFM}







procedure TForm1.FormCreate(Sender: TObject);

begin

DB_Insert := '불가능';

DBNavigator1.VisibleButtons := [nbFirst,nbPrior,nbNext,nbLast];

end;



procedure TForm1.BitBtn1Click(Sender: TObject);

begin

if BitBtn1.Caption = '추가(&A)' then

begin

DB_Insert := '가능';

BitBtn1.Caption := '취소(&C)';

BitBtn2.Enabled := False;

Table1.Append;

end

else

begin

DB_Insert := '불가능';

BitBtn1.Caption := '추가 (&A)';

BitBtn2.Enabled := True;

Table1.Cancel;

end;

DBEdit2.SetFocus;

end;



procedure TForm1.BitBtn3Click(Sender: TObject);

begin

if DB_Insert = '가능' then

begin

Table1.Post;

DB_Insert := '불가능';

BitBtn1.Caption := '추가(&A)';

BitBtn2.Enabled := True;



end

else

begin

if Table1.Modified then

Table1.Post;

end;

DBEdit2.SetFocus;

end;



end.

0  COMMENTS