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;这个逻辑上有什么问题啊
原密码不管对错都执行的

解决方案 »

  1.   

    在判断的地方设个断点看看取出来的值和EDIT的值分别是什么
      

  2.   

    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
                        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;这个哪里有错误啊!
      

  3.   

    if
    end
    把这个逻辑搞清楚先!!
    空格需要过滤下:trim(edit1.text)
    ?!
      

  4.   

     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
          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;
      

  5.   

    你 begin 和 end 全乱掉了啊不对应啊
      

  6.   

    最后第二个END 你对哪个啊
      

  7.   


     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
    语法没错
    就是无法修改密码