begin
if application.MessageBox('确定修改吗?','密码管理',MB_OKCANCEL)=IDOK then
begin
query1.SQL.clear;
query1.SQL.add('select * from renyuanbiao where username='''+denglu.Edit1.Text+'''');
query1.open; if query1.FieldByName('password').AsString<>edit2.Text
then
StatusBar1.Panels[1].Text:= '原密码不对' ;
if(Edit3.Text<>Edit4.Text)
then
StatusBar1.Panels[1].Text:= '确认口令不对' else
begin
// query1.SQL.add('select * from renyuanbiao where name='''+Edit1.Text+''' and password='''+Edit2.Text+'''');
query1.SQL.clear;
query1.SQL.add('update renyuanbiao set password='''+Edit3.Text+''' where username='''+Edit1.Text+'''');
query1.ExecSQL();
StatusBar1.Panels[1].Text:= '密码修改成功!';
end
end
else
StatusBar1.Panels[1].Text:= '用户工号或密码错误!'; Query1.Close; end;这个逻辑上有什么问题啊
原密码不管对错都执行的
if application.MessageBox('确定修改吗?','密码管理',MB_OKCANCEL)=IDOK then
begin
query1.SQL.clear;
query1.SQL.add('select * from renyuanbiao where username='''+denglu.Edit1.Text+'''');
query1.open; if query1.FieldByName('password').AsString<>edit2.Text
then
StatusBar1.Panels[1].Text:= '原密码不对' ;
if(Edit3.Text<>Edit4.Text)
then
StatusBar1.Panels[1].Text:= '确认口令不对' else
begin
// query1.SQL.add('select * from renyuanbiao where name='''+Edit1.Text+''' and password='''+Edit2.Text+'''');
query1.SQL.clear;
query1.SQL.add('update renyuanbiao set password='''+Edit3.Text+''' where username='''+Edit1.Text+'''');
query1.ExecSQL();
StatusBar1.Panels[1].Text:= '密码修改成功!';
end
end
else
StatusBar1.Panels[1].Text:= '用户工号或密码错误!'; Query1.Close; end;这个逻辑上有什么问题啊
原密码不管对错都执行的
begin
query1.SQL.clear;
query1.SQL.add('select * from renyuanbiao where username='''+denglu.Edit1.Text+'''');
query1.open; if query1.FieldByName('password').AsString<>edit2.Text
then
StatusBar1.Panels[1].Text:= '原密码不对' ;
if(Edit3.Text<>Edit4.Text)
then
StatusBar1.Panels[1].Text:= '确认口令不对' else
Edit3.Text:='';
Edit4.Text:='';
end else
begin
// query1.SQL.add('select * from renyuanbiao where name='''+Edit1.Text+''' and password='''+Edit2.Text+'''');
query1.SQL.clear;
query1.SQL.add('update renyuanbiao set password='''+Edit3.Text+''' where username='''+Edit1.Text+'''');
query1.ExecSQL();
StatusBar1.Panels[1].Text:= '密码修改成功!';
end
end
else
StatusBar1.Panels[1].Text:= '用户工号错误!'; Query1.Close; end;这个哪里有错误啊!
end
把这个逻辑搞清楚先!!
空格需要过滤下:trim(edit1.text)
?!
begin
query1.SQL.clear;
query1.SQL.add('select * from renyuanbiao where username=''' + denglu.Edit1.Text + '''');
query1.open; if query1.FieldByName('password').AsString <> edit2.Text
then
StatusBar1.Panels[1].Text := '原密码不对';
if (Edit3.Text <> Edit4.Text)
then
StatusBar1.Panels[1].Text := '确认口令不对' else
Edit3.Text := '';
Edit4.Text := '';
end else
begin
// query1.SQL.add('select * from renyuanbiao where name='''+Edit1.Text+''' and password='''+Edit2.Text+'''');
query1.SQL.clear;
query1.SQL.add('update renyuanbiao set password=''' + Edit3.Text + ''' where username=''' + Edit1.Text + '''');
query1.ExecSQL();
StatusBar1.Panels[1].Text := '密码修改成功!';
end
end
else
StatusBar1.Panels[1].Text := '用户工号错误!'; Query1.Close;end;
begin
if application.MessageBox('确定修改吗?','密码管理',MB_OKCANCEL)=IDOK then
begin
query1.SQL.clear;
query1.SQL.add('select * from renyuanbiao where username='''+denglu.Edit1.Text+'''');
query1.open; if query1.FieldByName('password').AsString=edit2.Text
then
begin if(Edit3.Text=Edit4.Text)
then
begin
query1.SQL.clear;
query1.SQL.add('update renyuanbiao set password='''+Edit3.Text+''' where username='''+Edit1.Text+'''');
query1.ExecSQL();
StatusBar1.Panels[1].Text:= '密码修改成功!'
end
else
begin
StatusBar1.Panels[1].Text:= '确认口令不对' ;
Edit3.Text:='';
Edit4.Text:='';
end
end
else
StatusBar1.Panels[1].Text:= '原密码不对' ;
end
语法没错
就是无法修改密码