.net - 尝试在 VB .NET 中执行 DTS 包时出现 "Invalid class string"

标签 .net sql-server dts

我有一个在我们的 MS SQL Server 2000 数据库服务器上运行的 DTS 包,并且需要一种方法让用户从自己的计算机上执行它。 (该包创建文件,然后由我的应用程序传输到客户端计算机。)我已在应用程序中包含“Microsoft DTSPackage Object Library”COM 引用,但在执行第一步时仍然收到“无效类字符串”错误。包被执行。我还尝试注册 SQL Server 2000 光盘的 redist.txt 文件中指定的所有 DLL。任何想法或建议将不胜感激。 DTS 包非常简单。它只是将数据从 SQL 数据库复制到 Visual FoxPro 表中。我执行该包的代码如下(其中大部分摘自 Microsoft 的知识库文章:http://support.microsoft.com/kb/321525)。

        Dim pkg As DTS.Package
        pkg = New DTS.Package
        Dim cpContainer As System.Runtime.InteropServices.ComTypes.IConnectionPointContainer
        cpContainer = CType(pkg, System.Runtime.InteropServices.ComTypes.IConnectionPointContainer)
        Dim cpPoint As System.Runtime.InteropServices.ComTypes.IConnectionPoint
        Dim PES As PackageEventsSink = New PackageEventsSink

        Dim guid As Guid = New Guid("10020605-EB1C-11CF-AE6E-00AA004A34D5")

        cpPoint = Nothing
        cpContainer.FindConnectionPoint(guid, cpPoint)

        Dim intCookie As Integer
        cpPoint.Advise(PES, intCookie)

        pkg.LoadFromSQLServer(DTS_SERVER_NAME, , , DTSSQLServerStorageFlags.DTSSQLStgFlag_UseTrustedConnection, dtsPassword, , , dtsName, Nothing)
        If pkg Is Nothing Then Throw New ApplicationException("The DTS Package could not be loaded from the SQL Server.")

        Dim pkgStep As DTS.Step
        For Each pkgStep In pkg.Steps
            pkgStep.Execute()
        Next

        pkg.UnInitialize()
        pkg = Nothing

        cpPoint.Unadvise(intCookie)
        cpPoint = Nothing
        cpContainer = Nothing
        PES = Nothing

最佳答案

如果您在用户 PC 上安装完整的 SQL Enterprise Manager 客户端工具作为测试,他们能否成功运行?也许您缺少一些要求。请记住,DTS 包本身将在用户的 PC 上本地执行,而不是在服务器上执行。

关于.net - 尝试在 VB .NET 中执行 DTS 包时出现 "Invalid class string",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2419625/

相关文章:

c# - 对于 i = 0,为什么 (i += i++) 等于 0?

.net - 检测到重入

.net - 如何从转储文件确定 GC 工作站与服务器模式

python - 使用 fast_executemany Python pyodbc 加速 pandas 数据帧的插入

sql-server - SQL Server : Conditional where clause (Equal) OR (LessThan or Equal)

sql-server - 从 SQL Server 2008 生成 xml

c# - 如何从 C# 中加载的 SSIS 包捕获事件?

c# - 使用带有加密连接字符串的 Application.LoadFromSqlServer() 加载 SSIS 包

c# - 如何防止其他应用程序窃取焦点?

sql-server - 在 SQL 2000 中打开一个 .BAS DTS 包?