如何从Visual Basic 6运行SSIS包?

时间:2021-11-09 11:33:16

Can anyone provide some information on how to run an integration services package, on an SQL server 2005 instance, from Visual Basic 6?

任何人都可以提供有关如何在SQL Server 2005实例上从Visual Basic 6运行集成服务包的一些信息吗?

Any help at all is much appreciated.

任何帮助都非常感谢。

2 个解决方案

#1


You need to have xp_cmdshell enabled, if it's not, execute: sp_configure 'xp_cmdshell', '1' in SSMS on your server.

您需要启用xp_cmdshell,如果不是,请在服务器上的SSMS中执行:sp_configure'xp_cmdshell','1'。

Create a store procedure, and put the following code in it:

创建一个存储过程,并将以下代码放入其中:

DECLARE @SSISPackage VARCHAR(1000)
DECLARE @cmd VARCHAR(max)
DECLARE @variable_value1 varchar(255)
DECLARE @Result int

SET @SSISPackage = 'C:\path_to_the_package\package_name.dtsx'
SET @cmd = 'dtexec /F "' + @SSISPackage + '"'   
// if you have variables in the package that need to be set up
// add them here
SET @cmd = @cmd + ' /SET \Package.Variables[User::somevariable1].Properties[Value];"' + @variable_value1 + '"'
SET @cmd = @cmd + ' /SET \Package.Variables[User::somevariable2].Properties[Value];"' + @variable_value2 + '"'
SET @cmd = @cmd + ' /SET \Package.Variables[User::somevariable3].Properties[Value];"' + @variable_value3 + '"'

EXECUTE @Result = master..xp_cmdshell @cmd, NO_OUTPUT

Then, call the stored procedure from VB6, via an ADODB.Command.

然后,通过ADODB.Command从VB6调用存储过程。

You have examples here:

你有这里的例子:

I hope it helps.

我希望它有所帮助。

#2


Probably easiest is to shell out and run dtexec

可能最简单的是外壳并运行dtexec

Alternatively, you could use the using Microsoft.SqlServer.Dts assemblies in .NET and wrap it in COM (or an EXE) and then call it from VB6.

或者,您可以在.NET中使用Microsoft.SqlServer.Dts程序集并将其包装在COM(或EXE)中,然后从VB6中调用它。

That second link has some other options which might apply to VB6 in some way, but would probably all result in wrapping the .NET code in a COM object or an EXE.

第二个链接有一些其他选项可能以某种方式应用于VB6,但可能都会导致将.NET代码包装在COM对象或EXE中。

#1


You need to have xp_cmdshell enabled, if it's not, execute: sp_configure 'xp_cmdshell', '1' in SSMS on your server.

您需要启用xp_cmdshell,如果不是,请在服务器上的SSMS中执行:sp_configure'xp_cmdshell','1'。

Create a store procedure, and put the following code in it:

创建一个存储过程,并将以下代码放入其中:

DECLARE @SSISPackage VARCHAR(1000)
DECLARE @cmd VARCHAR(max)
DECLARE @variable_value1 varchar(255)
DECLARE @Result int

SET @SSISPackage = 'C:\path_to_the_package\package_name.dtsx'
SET @cmd = 'dtexec /F "' + @SSISPackage + '"'   
// if you have variables in the package that need to be set up
// add them here
SET @cmd = @cmd + ' /SET \Package.Variables[User::somevariable1].Properties[Value];"' + @variable_value1 + '"'
SET @cmd = @cmd + ' /SET \Package.Variables[User::somevariable2].Properties[Value];"' + @variable_value2 + '"'
SET @cmd = @cmd + ' /SET \Package.Variables[User::somevariable3].Properties[Value];"' + @variable_value3 + '"'

EXECUTE @Result = master..xp_cmdshell @cmd, NO_OUTPUT

Then, call the stored procedure from VB6, via an ADODB.Command.

然后,通过ADODB.Command从VB6调用存储过程。

You have examples here:

你有这里的例子:

I hope it helps.

我希望它有所帮助。

#2


Probably easiest is to shell out and run dtexec

可能最简单的是外壳并运行dtexec

Alternatively, you could use the using Microsoft.SqlServer.Dts assemblies in .NET and wrap it in COM (or an EXE) and then call it from VB6.

或者,您可以在.NET中使用Microsoft.SqlServer.Dts程序集并将其包装在COM(或EXE)中,然后从VB6中调用它。

That second link has some other options which might apply to VB6 in some way, but would probably all result in wrapping the .NET code in a COM object or an EXE.

第二个链接有一些其他选项可能以某种方式应用于VB6,但可能都会导致将.NET代码包装在COM对象或EXE中。