加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

尝试在VB .NET中执行DTS包时“无效的类字符串”

发布时间:2020-12-17 07:27:21 所属栏目:百科 来源:网络整理
导读:我有一个在我们的MS SQL Server 2000数据库服务器上运行的DTS包,并且需要一种方法让用户从他们自己的机器上执行它. (该包创建文件,然后由我的应用程序传输到客户端计算机.)我已在应用程序中包含“Microsoft DTSPackage对象库”COM引用,但在第一步时仍然出现
我有一个在我们的MS SQL Server 2000数据库服务器上运行的DTS包,并且需要一种方法让用户从他们自己的机器上执行它. (该包创建文件,然后由我的应用程序传输到客户端计算机.)我已在应用程序中包含“Microsoft DTSPackage对象库”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上本地执行,而不是在服务器上执行.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读