开发者

"Invalid class string" while trying to execute DTS Package in VB .NET

开发者 https://www.devze.com 2022-12-22 18:08 出处:网络
I have a DTS package that runs on our MS SQL Server 2000 database server, and need a way for users to execute it from their own machines.(The package creates files that are then transferred by my appl

I have a DTS package that runs on our MS SQL Server 2000 database server, and need a way for users to execute it from their own machines. (The package creates files that are then transferred by my application to the client machine.) I have included the "Microsoft DTSPackage Object Library" COM reference in the application, but still get an "Invalid Class String" error when the first step of the package is executed. I have also tried registering all the DLLs specified in the redist.txt file of the SQL Server 2000 disc. Any thoughts or suggestions would be greatly appreciated. The DTS package is very simple. It just copies data from the SQL database into Visual FoxPro tables. My code that executes the package is below (much of it is taken from Microsoft's KB article: 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


If you install the full SQL Enterprise Manager client tools on the user PCs, as a test, can they run it successfully? Maybe you're missing some requirement. Remember that the DTS package itself will be executing locally on the user's PC, not on the server.


Try to register your DLL with REGASM /CODEBASE

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号