注册窗体代码:
unit Unit2;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DB, DBTables, StdCtrls;
type TForm2 = class(TForm) Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Label1: TLabel; Label2: TLabel; Label3: TLabel; Button1: TButton; Button2: TButton; Table1: TTable; procedure Button1Click(Sender: TObject); procedure FormShow(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form2: TForm2;
implementation
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject); begin table1.Open ; table1.SetKey ; table1.FieldByName('name').AsString :=edit1.Text ;
if not table1.GotoKey then begin if edit2.Text = edit3.Text then begin table1.Open ; table1.InsertRecord([edit1.Text ,edit2.Text ]); showmessage('注册成功'); table1.Close ; self.close; end else showmessage('两次输入密码不一致'); end else showmessage('用户名存在'); edit1.Clear ; edit2.Clear ; edit3.Clear ; edit1.SetFocus ;
end;
procedure TForm2.FormShow(Sender: TObject); begin edit1.Clear ; edit2.Clear ; edit3.Clear ; edit1.SetFocus ; end;
end.
点击那个按钮后,弹出对话框,就出现了上面的那个错误.