以下代碼是在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
新聞熱點
疑難解答
圖片精選