Page 1 of 1

TPgParam raises assertion error when cast as TParam

Posted: Mon 18 May 2009 22:57
by yozey
Hi, even though TPgParam descends from TDAParam which descends from TParam, using the following code raises and access violation with LoadFromFile

Code: Select all

TParam(MyParam).LoadFromFile('somefile', ftBlob); //where MyParam is a TParam
The assertion raised is that the Datatype is not supported. Shouldn't the above method work for a TParam descendant?

Posted: Tue 19 May 2009 07:07
by Plash
TDAParam works with BLOBs in different way then TParam. You cannot use TParam for the ftBlob data type. Some methods in TParam are not virtual and cannot be overriden. So you should use TDAParam or TPgParam.

Posted: Wed 20 May 2009 11:17
by yozey
My issue was a routine that filled TParams with values supplied. Since the routine uses the parent class to allow for usage with most TParam descendants, I could not now enforce a TPgParam/TDaParam as it would limit it to DevArt components.

I found a workaround however using the Assign procedure of TParam.

Code: Select all

var
  Pr: TParam;
begin
  Pr := TParam.Create(nil);
  try
    Pr.Assign(Param); // assign original param properties
    { Fill Pr with some data from supplied stream }
    Param.Assign(Pr); // Reassign data to supplied TParam
  finally
    Pr.Free;
  end;
This has so far worked with 2 different supplied TParam descendants.

Posted: Thu 21 May 2009 07:35
by Plash
This workaround shoud work correctly.