Table: Dataset not in Edit or Insert mode?(50分)

  • 主题发起人 主题发起人 peterluolaw
  • 开始时间 开始时间
P

peterluolaw

Unregistered / Unconfirmed
GUEST, unregistred user!
请各位帮我看一下面的代码到底有什么问题?
因为每次我试着删除记录时问题出现--
"Table: Dataset not in Edit or Insert mode?"
但实际上,发现记录的确是能被删除的!为什么会出现
这种情况?请赐教!unit Unit5;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms
Dialogs, Db, DBTables, DBCtrls, StdCtrls, ExtCtrls, Buttons, Unit1;

type
TForm5 = class(TForm)
Bevel1: TBevel;
Label1: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
DBText1: TDBText;
DBText2: TDBText;
DBText3: TDBText;
DBText4: TDBText;
DBText5: TDBText;
DBText6: TDBText;
DBText7: TDBText;
DBText8: TDBText;
DBText9: TDBText;
DBText10: TDBText;
DBText11: TDBText;
Panel1: TPanel;
Image1: TImage;
DBMemo1: TDBMemo;
Edit1: TEdit;
Button1: TButton;
Button2: TButton;
RadioGroup1: TRadioGroup;
DBNavigator1: TDBNavigator;
DataSource1: TDataSource;
Table1: TTable;
BitBtn1: TBitBtn;
BitBtn2: TBitBtn;
Label2: TLabel;
Label14: TLabel;
Edit2: TEdit;
Edit3: TEdit;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure BitBtn1Click(Sender: TObject);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form5: TForm5;

implementation

{$R *.DFM}

procedure TForm5.Button2Click(Sender: TObject);
begin
form5.close;
end;

//查询
procedure TForm5.Button1Click(Sender: TObject);
begin
if radiogroup1.ItemIndex=0 then
begin
table1.active:=false;
table1.indexname:='';
table1.active:=true;
end
else
begin
table1.active:=false;
table1.indexname:='comp';
table1.active:=true;
end;
table1.findnearest([edit1.text]);
end;

procedure TForm5.FormActivate(Sender: TObject);
begin
radiogroup1.itemindex:=0;
table1.active:=true;
edit1.setfocus;
end;

procedure TForm5.FormClose(Sender: TObject; var Action: TCloseAction);
begin
table1.active:=false;
edit1.text:='';
edit2.text:='';
edit3.text:='';
end;

//修改
procedure TForm5.BitBtn1Click(Sender: TObject);
begin
if (form1.edit1.text<>edit2.text) or (form1.maskedit1.text<>edit3.text) then
begin
application.messagebox('你输入的"用户名"或"密码"不正确!','验证出错',mb_ok+mb_iconwarning);
end
else
begin
// table1.edit;
// table1.post;
end;
edit2.text:='';
edit3.text:='';
end;

//删除
procedure TForm5.BitBtn2Click(Sender: TObject);
begin
if (form1.edit1.text<>edit2.text) or (form1.maskedit1.text<>edit3.text) then
begin
application.messagebox('你输入的"用户名"或"密码"不正确!','验证出错',mb_ok+mb_iconwarning);
end
else
begin
table1.edit;
table1.delete;//从这时开始出现问题的!
table1.post;
end;
edit2.text:='';
edit3.text:='';
end;

end.

 
//删除
procedure TForm5.BitBtn2Click(Sender: TObject);
begin
if (form1.edit1.text<>edit2.text) or (form1.maskedit1.text<>edit3.text) then
begin
application.messagebox('你输入的"用户名"或"密码"不正确!','验证出错',mb_ok+mb_iconwarning);
end
else
begin
table1.delete;//从这时开始出现问题的!
end;
edit2.text:='';
edit3.text:='';
end;
 
来晚一步,让纸狐狸给答了。
 
调用delete后,不用post[:)]
我也要分!!
 
不好意思再问一下,EDIT,INSERT,APPEND,UPDATE这些就需要使用POST方法吗?
 

Similar threads

后退
顶部