Accessing an existing connection from an SSIS Script Component

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
lb483
Posts: 3
Joined: Fri 24 Apr 2020 08:34

Accessing an existing connection from an SSIS Script Component

Post by lb483 » Fri 24 Apr 2020 08:50

I'm using the MySqlLoader in an SSIS script component (C#) as it gives significant performance benefits over other methods.

However as part of the code, I'm having to create a new MySqlConnection object to open the target database. As the package already contains a connection manager to the database, is it possible to make use of this without having to create a new one?

Code: Select all

MySqlConnection mySqlConnx = (MySqlConnection)Connections.Connection;
results in the error:

Code: Select all

Unable to cast COM object of type 'System.__ComObject' to class type 'Devart.Data.MySql.MySqlConnection'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface.
Is there a way to reuse this existing component? My current workaround is:

Code: Select all

MySqlConnection mySqlConnx = new MySqlConnection(Connections.Connection.ConnectionString);
mySqlConnx.Password = "***";
If I could reuse the existing connection manager, I wouldn't have to code in the password but I can't find a way to do this.

Thanks.
Last edited by lb483 on Fri 24 Apr 2020 10:24, edited 1 time in total.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: Accessing an existing connection from an SSIS Script Component

Post by Shalex » Fri 24 Apr 2020 16:30


Post Reply