开发者

invalid argument delphi

开发者 https://www.devze.com 2023-02-21 01:05 出处:网络
I get an error while saving a string. the error is: prject prKlanten.exe raised exeption class EVariantInvalidArgError with message \'invalid argument\'.

I get an error while saving a string. the error is: prject prKlanten.exe raised exeption class EVariantInvalidArgError with message 'invalid argument'.

    var
  fmOrder: TfmOrder;
  orderid: string;

implementation

{$R *.dfm}
uses unDm, unInloggen, unKlant, unKeuze, unbeheer, unAccount, unOrderChange;

procedure TfmOrder.btOpslaanOClick(Sender: TObject);
  begin
    dm.atOrder.open;
    dm.atOrder.Append;
    dm.atOrder ['OrderStatus']             := ('Aangemeld');
    dm.atOrder ['klantID']                 := fminloggen.userid;
    dm.atOrder ['OrderDatum']              := leOphaalDatum.text;
    dm.atOrder ['Opmerkingen']             := leOpmerkingen.text;
    fminloggen.userid                      := dm.atOrder ['KlantID'];
    dm.atOrder ['OrderID']                 := fmOrder.orderid ;   
    dm.atOrder.post;
    fmOrderChange.ShowModal;
  end;
end.

the line :

dm.atOrder ['OrderID']                 := fmOrder.orderid ;

gives the error. I spelled everything correctly en the fminloggen.userid does works.

does anyone know what the problem is.

thanks in advance!

Jasper

I did the same in an other form:

public
  var inlognaam : string;
  userid    : string;
end;

var
  fmInloggen: TfmInloggen;

implementation

{$R *.dfm}

uses unKlant, unbeheer, unaccount, unKeuze,unDm;

procedure TfmInloggen.BTinloggenClick(Sender: TObject);

var Gevonden: boolean;
  begin
    dm.atInlog.open;
      Gevonden := false;
    while (not Gevonden) and (not dm.atInlog.eof) do
      begin
          if dm.atInlog['email'] = leUser.Text
          then
        begin
         Gevonden := true ;
         fminloggen.inlognaam := dm.atInlog['email'];
         fminloggen.userid    := dm.atInlog['KlantID'];
        end
          else
        dm.atInlog.Next
      en开发者_如何转开发d;

  if Gevonden and (dm.atInlog['Password'] = lePassword.text)
    then
     if dm.atInlog['Autorisatie'] = '1'
       then
       begin
          fmKlant.Caption := dm.atInlog['email'];
          fmKeuze.ShowModal;
       end
        else if dm.atInlog['Autorisatie'] = '2'
         then
         begin
           fmKlant.Caption := dm.atInlog['email'];
           fmBeheer.ShowModal;
         end;
    dm.atInlog.Close;
  end;

except this is with userid


In your working example you have:

public
  var inlognaam : string;
  userid    : string;
end;

Assuming from this that they are both fields in a form declaration.

In your non-working examply you have:

  var
fmOrder: TfmOrder;
orderid: string;

fmOrder seems to be the IDE generated instance variable of the form. If orderid follows that then it can't be a field of the form declaration.

Are you sure that you have orderid declared as a field in the TfmOrder form declaration? As you say in your comment to @BugFinder's answer that you cannot insert the myStringVar := fmOrder.orderId; line, I suspect that you get a compiler error on that and that could well be because orderId is not a member field of fmOrder...


Are you sure that and this point fmOrder is not invalid? Debug it, and follow the lines through, check that dm.atOrder['OrderID'] is valid, as well as fmOrder is valid. It would need to be one of the two.

0

精彩评论

暂无评论...
验证码 换一张
取 消