procedure TFrmLogin.BtnLoginClick(Sender: TObject);
begin
DataModule1.UserTable.Active:=true;
if EdtUser.Text='' then
begin
ShowMessage('请输入用户名!');
EdtUser.SetFocus;
exit;
end;
if DataModule1.UserTable.Locate('username;userpwd',VarArrayOf([EdtUser.Text,EdtPassword.Text]),
[]) then
begin
UName:=EdtUser.Text;
Upwd:=EdtPassword.Text;
FormMain.Show;
FrmLogin.Hide;
end
else
begin
ShowMessage('请输入正确的密码');
EdtPassword.SetFocus;
exit;
end;
end;
ADOConnection1.Connected:=true;
>> adotable1.Connection:=ADOConnection1;
>> adotable1.TableName:=user;
if not ADOTable1.Locate('username',username,[])then
我这样做怎么发生错误
procedure Tlogin.LoginBtnClick(Sender: TObject);
begin
username:=login.Edit1.Text;
paswd:=login.Edit2.Text;
pathst:=getcurrentdir()+'\mdb\equip.mdb;';
st:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\EquipManage\mdb\equip.mdb;Persist Security Info=False';
ADOConnection1.ConnectionString:=st;
ADOConnection1.Connected:=true;
if not ADOTable1.Locate('username',username,[])then
begin
FLogError.ShowModal;
ADOTable1.Close;
ADOConnection1.Close;
end
else if ADOTable1.FieldValues['pswd']=paswd then
begin
FsearchG1.ShowModal;
login.Hide;
ADOTable1.Close;
ADOConnection1.Close;
end
else begin
FLogError.ShowModal;
ADOTable1.Close;
ADOConnection1.Close;
end;
// edit1.text为用户名输入框;
// edit2.text为密码输入框
user.Filter:='id='''+edit1.Text+'''';
user.Filtered:=true;
user.Open;
if user.RecordCount=1 then //判断登陆名
begin
if user['passwd']=edit2.Text then
begin
....查询
end
else showmessage('密码不对!');
end
else showmessage('无此用户!')
procedure TForm5.Button1Click(Sender: TObject);
begin
try
table1.Filter:='name='''+edit1.text+'''';
table1.Filtered:=true;
table1.Open;
Except
Application.MessageBox('数据库连接失败,请于系统管理员联系。','数据库连接错误!',MB_OK);
Application.Terminate;
end;
if table1.recordcount=1 then
begin
if table1['password']=edit2.text then
begin
sUserID := Trim(edit1.Text);
sUserPW := Trim(edit2.Text);
self.ModalResult:=mrOK;
end
else
begin
Application.MessageBox('密码输入有误,请确认密码!','密码不正确!',MB_OK);
edit2.SetFocus;
end;
end
else Application.MessageBox('请确认用户名是否正确!','无此用户!',MB_OK); edit1.SetFocus;
end;
procedure TForm5.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then { 如 果 按 下 了 回 车 键 }
begin
Key := #0; { 吃 掉 回 车 键 }
Perform(WM_NEXTDLGCTL,0,0); { 移 动 到 下 一 个 控 制 }
end;
end;
procedure TForm5.Button2Click(Sender: TObject);
begin
close;
end;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if not adotable1.Locate('name',edit1.Text,[]) then
showmessage('不存在这个用户,登陆失败')
else
if adotable1.FieldValues['password']=edit2.Text then
begin
form2.Show;
form1.Hide;
end
else
begin
showmessage('密码错误,请从新登陆');
application.Terminate;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
form1.close;
end;