SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


accessing connection managers in script tasks


accessing connection managers in script tasks

Author
Message
cafescott
cafescott
Old Hand
Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)Old Hand (398 reputation)

Group: General Forum Members
Points: 398 Visits: 733
Hello,

I'm trying to use an OLEDB connection in a script task. There's a fair amount of documentation on this topic, such as:
http://msdn.microsoft.com/en-us/library/ms136018.aspx#Y718
http://social.msdn.microsoft.com/Forums/en/sqlintegrationservices/thread/dbf15acc-ed02-442d-8b56-4e170d7b89a2
http://blogs.msdn.com/b/mattm/archive/2008/08/22/accessing-oledb-connection-managers-in-a-script.aspx

The only problem is I can't get anything to work. (Nothing like examples that produce errors.)

For example, when I mimic the code in the first link above with this VB.NET code:


Dim myConnection As SqlConnection
Dim cm As ConnectionManager
cm = Dts.Connections("DB_cm")
myConnection = DirectCast(Dts.Connections("DB_cm").AcquireConnection(Dts.Transaction), SqlClient.SqlConnection)

--OR--
myConnection = DirectCast(cm.AcquireConnection(Dts.Transaction), SqlClient.SqlConnection)



Then debug the package, I get this error on the "Directcast" line:

System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to class type 'System.Data.SqlClient.SqlConnection'.


Does anyone have an idea why I can't get code in a Script Task to execute which also appears in the Microsoft KB?

thanks,
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search