以下代码是在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
新闻热点
疑难解答
图片精选