S
sundayone
Unregistered / Unconfirmed
GUEST, unregistred user!
Public Sub Main()
Dim oPackage As DTS.Package
Dim oStep As DTS.Step
Dim oTask As DTS.Task
Dim oCustTask As DTS.ExecutePackageTask
Set oPackage = New DTS.Package
'Create step and task, link step to task.
Set oStep = oPackage.Steps.New
oStep.Name = "ExecPkgStep"
Set oTask = oPackage.Tasks.New("DTSExecutePackageTask")
[red]Set oCustTask = oTask.CustomTask[/red]
[blue] // 这行代码在delphi中我用
// oCustTask := ExecutePackageTask(oTask.CustomTask);
// 运行时在oPackage.Execute处出现内存非法访问错误!
// ExecutePackageTask 是DTSpkg.dll中定义的一接口类型
// 其他行代码转换都没问题,我该如何做? 请指教 谢谢! [/blue]
oCustTask.Name = "ExecPkgTask"
oStep.TaskName = oCustTask.Name
oPackage.Steps.Add oStep
Set oStep = Nothing
'Specify package to be run.
oCustTask.PackagePassword = "user"
oCustTask.FileName = "C:/DTS_UE/TestPkg/VarPubsFields.dts"
'Link task to package, run package.
oPackage.Tasks.Add oTask
Set oCustTask = Nothing
Set oTask = Nothing
[red]oPackage.Execute[/red]
Set oPackage = Nothing
End Sub
Dim oPackage As DTS.Package
Dim oStep As DTS.Step
Dim oTask As DTS.Task
Dim oCustTask As DTS.ExecutePackageTask
Set oPackage = New DTS.Package
'Create step and task, link step to task.
Set oStep = oPackage.Steps.New
oStep.Name = "ExecPkgStep"
Set oTask = oPackage.Tasks.New("DTSExecutePackageTask")
[red]Set oCustTask = oTask.CustomTask[/red]
[blue] // 这行代码在delphi中我用
// oCustTask := ExecutePackageTask(oTask.CustomTask);
// 运行时在oPackage.Execute处出现内存非法访问错误!
// ExecutePackageTask 是DTSpkg.dll中定义的一接口类型
// 其他行代码转换都没问题,我该如何做? 请指教 谢谢! [/blue]
oCustTask.Name = "ExecPkgTask"
oStep.TaskName = oCustTask.Name
oPackage.Steps.Add oStep
Set oStep = Nothing
'Specify package to be run.
oCustTask.PackagePassword = "user"
oCustTask.FileName = "C:/DTS_UE/TestPkg/VarPubsFields.dts"
'Link task to package, run package.
oPackage.Tasks.Add oTask
Set oCustTask = Nothing
Set oTask = Nothing
[red]oPackage.Execute[/red]
Set oPackage = Nothing
End Sub