下列程式碼是VB.NET(Framework 2.0)中呼叫SQLServer2005 的Intergration Service中DTS套件。
1 如果要在WebService中呼叫DTS,必須用VB.NET語言。因為如果用C#寫WebService的話,將無法引用Microsoft.SqlServer.ManagedDTS元件。
2 將NETWORK SERVICE帳號加入Administrator群組中,否則將無法執行DTS。 (會帶來安全漏洞)
1 Imports Microsoft.SqlServer.Dts.Runtime
2
3 'WebService程式碼
4
5 Public Function ExecutePackage() As Integer
6 Dim pkg As String = "D:DevelopmentProgramePackageDevPackageMG-TSJF-PKG.dtsx"
7
8 Dim app As Application = New Application()
9 Dim p As Package = app.LoadPackage(pkg, Nothing)
10 'p.InteractiveMode = True
11
12 Dim vir As Variables = p.Variables
13 vir("用戶::PackageID").Value = 4
14
15 If p.Execute(Nothing, vir, Nothing, Nothing, Nothing) = DTSExecResult.Success Then
16 Return 0
17 Else
18 Return 1
19 End If
20 End Function
http://www.cnblogs.com/liguancong/archive/2006/08/29/489681.html