这个你看看先
procedure TrdmLogin.UserLogin(const vUsername, vPassword,
  vHidenPassword: WideString; var vErrorCode: OleVariant);
var
  UserName , Password , HidenPassword : String;
begin
  UserName := Trim(vUserName);
  Password := Trim(vPassword);
  HidenPassword := Trim(vHidenPassword);  qryMain.Close;
  qryMain.SQL.Clear;
  qryMain.SQL.Add('SELECT * FROM userInformation');
  qryMain.SQL.Add('WHERE userName = :pUserID');
  qryMain.Parameters.ParamValues['pUserID'] := UserName;
  if qryMain.Prepared = False then
  begin
    qryMain.Prepared := True;
  end;
  qryMain.Open;
  if  qryMain.RecordCount > 0 then //用户名存在
  begin
    if trim(qryMain.FieldByName('userPassword').AsString)<> Password then
    begin
      vErrorCode := 1; //口令错误
    end
    else
    begin
      if trim(qryMain.FieldByName('cryticPassword').AsString) <> HidenPassword then
      begin
        vErrorcode := 2; //隐含口令错误,需要重新注册
      end
      else
      begin
        if qryMain.FieldByName('userTerm').AsDateTime < Now then
        begin
          vErrorcode := 3; //用户超期,请丫续费
        end
        else
        begin
          vErrorCode := 0; //用户正常登陆
        end;
      end;
    end;
  qryMain.Close;
  end
  else
  begin
    qryMain.Close;
    qryMain.SQL.Clear;
    qryMain.SQL.Add('SELECT * FROM teacherInformation');
    qryMain.SQL.Add('WHERE teacherName = :pUserID');
    qryMain.Parameters.ParamValues['pUserID'] := UserName;
    if qryMain.Prepared = False then
    begin
      qryMain.Prepared := True;
    end;
    qryMain.Open;
    if qryMain.RecordCount > 0 then
    begin
      if trim(qryMain.FieldByName('teacherPassword').AsString) = Password then
      begin
        vErrorcode := 4; //老师成功登陆
      end
      else
      begin
        vErrorcode := 1; //口令错误
      end;
    qryMain.Close;  
    end
    else
    begin
      qryMain.Close;
      qryMain.SQL.Clear;
      qryMain.SQL.Add('SELECT * FROM administrterInformation');
      qryMain.SQL.Add('WHERE administratorName = :pUserID');
      qryMain.Parameters.ParamValues['pUserID'] := UserName;
      if qryMain.Prepared = False then
      begin
        qryMain.Prepared := True;
      end;
      qryMain.Open;
      if qryMain.RecordCount > 0 then
      begin
        if trim(qryMain.FieldByName('administratorPassword').AsString) = Password  then
        begin
          vErrorcode := 5; //管理员成功登陆
        end
        else
        begin
          vErrorCode := 1; //口令错误
        end;
      end
      else
      begin
        vErrorCode := 6 //没有这个用户,请先提示注册
      end;
    qryMain.Close;  
    end;
  end;
end;