怎样用ASP调用DTS 程序?

xiangyyy 2006-04-04 05:24:20
有用过的能详细说说DTS 组件的方法属性吗?

下面是VB的过程:

DTS Programming


Executing DTS Packages in Visual Basic
After you have created the necessary Data Transformation Services (DTS) objects, set their properties and added them to the appropriate collections, use the Execute method of the Package2 object to run the package. For more information about handling errors raised by the Execute method, see DTS Error Handlers in Visual Basic.

If the Package2 object is to be used again (for example, for saving or running), or if the application is to perform significant processing outside of DTS after the DTS package is run, it is recommended that you call the Package2 UnInitialize method. UnInitialize performs various clean-ups, for example, re-initializing global variables, closing user-opened connections, closing the log, releasing threads, and terminating event connection points.

Before calling UnInitialize, it is strongly recommended that you release references to all DTS objects, except the Package2 object, through which you are going to run Uninitialize. This includes additional Package or Package2 object variables that you have declared WithEvents in order to handle package events.

You can release references by either setting the appropriate object variables to Nothing or arranging your code so that they go out of scope. If you fail to do this, resources such as computer memory will not be released by Uninitialize, giving the appearance of a memory leak.

ExampleThe following code example shows a DTS package using an ExecutePackageTask, through the Execute and UnInitialize methods:

Private WithEvents mobjPkgEvents As DTS.Package
. . .
Private Sub RunPackage()
'Run the package stored in file C:\DTS_UE\TestPkg\VarPubsFields.dts.
Dim objPackage As DTS.Package2
Dim objStep As DTS.Step
Dim objTask As DTS.Task
Dim objExecPkg As DTS.ExecutePackageTask

On Error GoTo PackageError
Set objPackage = New DTS.Package
Set mobjPkgEvents = objPackage
objPackage.FailOnError = True

'Create the step and task. Specify the package to be run, and link the step to the task.
Set objStep = objPackage.Steps.New
Set objTask = objPackage.Tasks.New("DTSExecutePackageTask")
Set objExecPkg = objTask.CustomTask
With objExecPkg
.PackagePassword = "user"
.FileName = "C:\DTS_UE\TestPkg\VarPubsFields.dts"
.Name = "ExecPkgTask"
End With
With objStep
.TaskName = objExecPkg.Name
.Name = "ExecPkgStep"
.ExecuteInMainThread = True
End With
objPackage.Steps.Add objStep
objPackage.Tasks.Add objTask

'Run the package and release references.
objPackage.Execute

Set objExecPkg = Nothing
Set objTask = Nothing
Set objStep = Nothing
Set mobjPkgEvents = Nothing

objPackage.UnInitialize
End Sub



...全文
105 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiangyyy 2006-04-06
  • 打赏
  • 举报
回复
为什么没有人用过呢?
sky0120 2006-04-05
  • 打赏
  • 举报
回复
UP,没用过
xiangyyy 2006-04-05
  • 打赏
  • 举报
回复
没有人用过吗?

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧