以下代碼是在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 <WebMethod()> _
5 Public Function ExecutePackage() As Integer
6 Dim pkg As String = "D:\Development\Programe\PackageDev\Package\MG-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