Board index » delphi » Unit2.pas(36): Incompatible types: 'CustomTask' and 'DataPumpTask'

Unit2.pas(36): Incompatible types: 'CustomTask' and 'DataPumpTask'

Hi
I'm writing an application that is suppossed to create and execute a dts
package but I cant make a datapumptask because

otask:=sPackage.Tasks.New('DTSDataPumpTask');
oPumptask:=oTask.CustomTask;

just results in

Error] Unit2.pas(36): Incompatible types: 'CustomTask' and 'DataPumpTask'

what am I doing wrong ?
anyone ?

regards

anders

 

Re:Unit2.pas(36): Incompatible types: 'CustomTask' and 'DataPumpTask'


Quote
Anders Nielsen wrote in message <8aoano$s...@bornews.borland.com>...
>I'm writing an application that is suppossed to create and execute a dts
>package but I cant make a datapumptask because

>otask:=sPackage.Tasks.New('DTSDataPumpTask');
>oPumptask:=oTask.CustomTask;

>just results in

>Error] Unit2.pas(36): Incompatible types: 'CustomTask' and 'DataPumpTask'

You cannot assign an ancestor class object to a variable of a descendant
type. You have two choices:

1. Change oPumpTask to be of type CustomTask. Any methods you call that are
inherited and/or overridden in type DataPumpTask will still be correctly
called (polymorphism).

2. Use a hard cast:
  oPumptask:=DataPumpTask(oTask.CustomTask);

--
Wayne Niddery - WinWright Consulting
RADBooks - http://members.home.net/wniddery/
You have a Right to Free Speech, but not the right to make me listen, nor to
use my property as a soapbox.

Other Threads