我有一个用户注册过程,它使用 MYDAC 组件将用户信息存储到我的数据库中。目前它允许重复用户,这不是我的意图。我的代码在下面,但我不知道问题出在哪里。
procedure TForm1.Button1Click(Sender: TObject);
begin
if (edit1.Text <> '') and (edit2.Text <> '') and (edit3.Text <> '') and
(edit4.Text <> '') then
begin
MyQuery1.Close;
MyQuery1.SQL.Text := 'select * from uyeler '+
'where nick=:0 and mail=:0 and site=:0';
MyQuery1.Params[0].AsString:=edit1.text;
MyQuery1.Params[0].AsString:=edit2.text;
MyQuery1.Params[0].AsString:=edit3.text;
MyQuery1.open;
if MyQuery1.RecordCount = 0 then
MessageDlg('The same information! Try again.', mtError, [mbOK], 0)
else
MyQuery1.Close;
MyQuery1.SQL.Text := 'INSERT INTO uyeler (nick, mail, site, sifre) VALUES '+
'(:nick, :mail, :site, :sifre)';
MyQuery1.ParamByName('nick').AsString := Edit1.text;
MyQuery1.ParamByName('mail').AsString := Edit2.text;
MyQuery1.ParamByName('site').AsString := Edit3.text;
MyQuery1.ParamByName('sifre').AsString := Edit4.text;
MyQuery1.Execute;
Button1.Enabled := False;
MessageDlg('Mission complate!', mtInformation, [mbOK], 0);
Edit1.Clear;
Edit2.Clear;
Edit3.clear;
Edit4.Clear;
PageControl2.Visible := False;
PageControl1.Visible := True;
end
else
begin
MessageDlg('Information is missing! Try again.', mtWarning,[mbOK],0);
end;
end;
我怎样才能防止注册相同?在这种情况下我该怎么办?