Using DTS through COM


2003-12-08 05:57:35 PM
delphi85
The following typecast : vCustomTask := ExecuteSQLTask(vTask.CustomTask);
is not working. I am getting an invalid pointer reference when trying to
access the
object properties. Any ideas.
procedure TForm1.Button1Click(Sender: TObject);
var
vConnection:Connection;
vTask:Task;
vCustomTask:ExecuteSQLTask;
vStep : Step;
tt : WideString;
begin
vConnection := Package1.Connections.New('SQLOLEDB.1');
With vConnection do
begin
Name := 'PTS';
ID := 1;
Reusable := True;
ConnectImmediate := False;
DataSource := 'fpis';
UserID := 'sa';
Password := 'sa';
UseTrustedConnection := False;
ConnectionTimeout := 30;
Catalog := 'PTS';
end;
Package1.Connections.Add(vConnection);
vTask := Package1.Tasks.New('DTSExecuteSQLTask');
vCustomTask := ExecuteSQLTask(vTask.CustomTask);
vCustomTask.CommandTimeout := 0;
vCustomTask.Name := 'DoStuff';
vCustomTask.Description := 'sdadasDelete';
vCustomTask.ConnectionID := 1;
tt := 'DELETE FROM tb_PlayerType1';
vCustomTask.SQLStatement := tt;
Package1.Tasks.Add(vTask);
vStep := Package1.Steps.New;
With vStep do
begin
Name := 'Step1';
Description := 'sDescription';
TaskName := 'DoStuff';
AddGlobalVariables := True;
CloseConnection := False;
IsPackageDSORowset := False;
DisableStep := False;
JoinTransactionIfPresent := False;
CommitSuccess := False;
RollbackFailure := False;
ExecuteInMainThread := False;
RelativePriority := DTSStepRelativePriority_Normal;
end;
Package1.Steps.Add(vStep);
Package1.Execute;
end;