Delphi中有4个控件 Edit1,Edit2,Edit3和ADOQuery.Edit1表示旧密码,Edit2表示输入的新密码,Edit3表示确认新密码。如果我用abc登录,旧修改abc的密码,如果用admin登录,就修改admin的密码。就是不同的登录用户修改该登录用户的密码。修改当前用户的密码。
解决方案 »
- 急......afxwin.inl assertion error,delphi调用C++含窗体的dll出错
- form.showmodal是什么意思
- 关于事件的问题?谢谢!
- Free方法不能够把一个对象从内存中清除?
- 在局域网中,用ado连接sql server,是不是就象操作本地数据库一样?
- 如何解密VCD,最近市面上出现了不少的加密VCD光盘,打开电脑的光盘,什么都没有,不知各位有什么解密的方法!
- 关于引用richtextbox 控件的问题!
- 如何设置BDE
- 如何监控局域网内其他SQL数据库的操作??
- :各位大哥,关于决策支持的问题,请救救小弟。。
- delphi开发一个系统,里面有多张表。一张表用一个query还是所有公用一个query
- 虚拟桌面的利用
begin
if edit2.text = edit3.text then
begin
with adoquery do
begin
close;
sql.text := ' updata table1 set password ='+quotedstr(edit2.text)+ ' where username ='+quotedstr(用户名);
ExecSQL;
end;
end
else
begin
//提示两次输入的密码不一致
end;
end
else
begin
//提示旧密码不正确
end;随手写的 ,基本上就这样了
begin
if edit2.Text<>edit3.Text then
begin
messagebox(handle,'确认码不正确,请检查!','提示',MB_OK+MB_ICONERROR);
edit3.SetFocus;
edit3.SelectAll;
exit;
end;
//先查询出来原始密码,然后进行对比
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from SFIS_User where UserCode='''+copy(combobox1.Text,1,6)+'''');
open;
YSmima:=fieldbyname('PassWord').AsString;
end; if Edit1.Text<>YSmima then
begin
messagebox(handle,'原始密码输入不正确!','提示',MB_OK+MB_ICONinformation);
Exit;
end; with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from SFIS_User where UserCode='''+copy(combobox1.Text,1,6)+'''');
open;
Edit;
fieldbyname('PassWord').AsString:=edit2.Text;
post;
messagebox(handle,'密码修改成功!','提示',MB_OK+MB_ICONinformation);
end;
end;
var
sql:string;
begin
sql:='update op_info set op_password=:a where op_name=:b';
if (edt_old.Text)<>(LoginForm.edt_pwd.Text) then
begin
MessageBox(handle,'旧密码有误','提示',MB_OK or MB_ICONERROR);
end
else if edt_new.Text='' then
begin
MessageBox(Handle,'密码不能为空','提示',MB_OK or mb_iconinformation);
end
else if (edt_ok.Text)<>(edt_new.Text) then
begin
MessageBox(Handle,'两次新密码不一致,请重输','提示',MB_OK or mb_iconinformation); end
else
begin
qry.Close;
qry.SQL.Clear;
qry.SQL.Add(sql);
qry.Parameters.ParamByName('a').Value:=edt_new.Text;
qry.Parameters.ParamByName('b').Value:=LoginForm.edt_username.Text;
qry.ExecSQL;
MessageBox(Handle,'修改成功','提示',MB_OK or MB_ICONINFORMATION);
UnitLogin.Log.WriteString('login','password',edt_new.Text);
end;
end;LoginForm表示登录窗口
如一致则更新数据库。