Monday, March 19, 2012

Does LoadFromSqlServer2 method work?

Hi. There's little documentation on the Microsoft.SqlServer.Dts.Runtime.Application "LoadFromSqlServer2" method, and even less via any search engine.

http://msdn2.microsoft.com/en-us/library/microsoft.sqlserver.dts.runtime.application.loadfromsqlserver2.aspx

I cannot seem to ever get the method to work; it returns "InvalidCastException: No such interface supported."

Is this code-speak for "does not work at this time" ?

Sample code (add a reference to c:\Program Files\Microsoft SQL Server\90\SDK\Assemblies\Microsoft.SQLServer.ManagedDTS.dll)

Dim app As New Microsoft.SqlServer.Dts.Runtime.Application

Dim pkg As Microsoft.SqlServer.Dts.Runtime.Package

Dim cnDatasource As New System.Data.SqlClient.SqlConnection

cnDatasource.ConnectionString = _

"Data Source=SQLOLEDB;SERVER=" & m_Datasource & ";Initial Catalog=msdb;Integrated Security=SSPI"

cnDatasource.Open()

pkg = app.LoadFromSqlServer2(m_PackageFolderPath & m_PackageName, cnDatasource, Nothing)

I am aware of the "LoadFromSqlServer" and "LoadFromDtsServer" methods; I like the idea of the Win-NT authentication (theoretically) available in the "LoadFromSqlServer2" method.

Did you read the first line of that link you sent?

"This method supports the SQL Server 2005 infrastructure and is not intended to be used directly from your code. "

|||

I guess I didn't. I've not met documentation that I wasn't supposed to use.

Thanks for the fact... it would have really been useful.

No comments:

Post a Comment