【发布时间】:2020-07-03 15:44:46
【问题描述】:
我正在尝试通过 MS Access VBA 使用具有动态执行文件名的单个 .dtsx 文件。我正在尝试将其作为已经在工作中创建的 Access 工具的一部分。而我
我已经能够解决将 .dtsx 链接到同一文件夹中的多个文件的问题,方法是将每个文件重命名为一个单一的、唯一的名称,运行 .dtsx,然后将名称改回来。但是,不一定保证文件夹目录,因为许多其他用户可能会使用该工具。
Imports Microsoft.SqlServer.Dts.Runtime
Module ApplicationTests
Sub Main()
' The variable pkg points to the location of the
' ExecuteProcess package sample that was installed with
' the SSIS samples.
Dim pkg As String = _
"C:\Program Files\Microsoft SQL Server\100\Samples\Integration Services" & _
"\Package Samples\ExecuteProcess Sample\ExecuteProcess\UsingExecuteProcess.dtsx"
Dim app As Application = New Application()
Dim p As Package = app.LoadPackage(pkg, Nothing)
' Now that the package is loaded, we can query on
' its properties.
Dim n As Integer = p.Configurations.Count
Dim p2 As DtsProperty = p.Properties("VersionGUID")
Dim pl As DTSProtectionLevel = p.ProtectionLevel
Console.WriteLine("Number of configurations = " & n.ToString())
Console.WriteLine("VersionGUID = " & CType(p2.GetValue(p), String))
Console.WriteLine("ProtectionLevel = " & pl.ToString())
Console.Read()
End Sub
End Module
这是我在https://docs.microsoft.com/en-us/sql/integration-services/building-packages-programmatically/creating-a-package-programmatically?view=sql-server-ver15 找到的代码,但它仅适用于我无法访问的 VB.Net。我希望模仿这个想法,但在 Access VBA - 创建/修改 SSIS 包。
【问题讨论】:
-
如果您导航到
C:\Windows\Microsoft.NET\Framework,您是否会在其中一个文件夹中看到 csc.exe(即 v2.0.50727、v4.0.30319)? -
另外,您上面的代码是否真的工作或者代表您希望用 vbscript/vba 完成什么?
-
我没有 csc.exe 文件。
-
我假设代码有效,但我无法在我的设备上对其进行测试。但是,它涉及到对 SSIS 包的修改,我希望从中创建类似的东西。