简体   繁体   中英

Adding SSIS Connections Programmatically - Oracle Provider for OLE DB

I'm writing a C# application to generate an SSIS package.

Part of this involves adding database connection managers - using the library Microsoft.SqlServer.Dts.Runtime . The following line of code shows how this can be done:

ConnectionManager cm = pkg.Connections.Add("OLEDB");

In the above code, I am adding an OLEDB connection, which creates a connection with the provider "Native OLEDB\\SQL Native Client" .

I do not want this, I am wanting to have the provider Oracle Provider for OLEDB instead.

The following sites show the different connection manager types:

http://msdn.microsoft.com/en-us/library/ms136093.aspx

http://msdn.microsoft.com/en-us/library/ms140203.aspx

But none suggest being able to use the Oracle OLEDB Provider, and the Oracle type specified on the second link is only valid for SQL 2008.

Am I going to have to go down the route of developing my own custom manager as described here?: http://msdn.microsoft.com/en-us/library/ms403359.aspx

Any help would be appreciated

James

You have to set the connection string on the OLEDB connection to tell it to use the Oracle provider similar to below:

Package pkg = new Package();
ConnectionManager manager = pkg.Connections.Add("OLEDB");
manager.ConnectionString = "Data Source=DEVORA.my.OracleDB;User ID=oracleUser;Provider=MSDAORA.1;Persist Security Info=True;";
manager.Name = "OracleDev";

Obviously you would have to build yourself a valid connection string for your environment (hint: construct one in SSIS designer first and pick out its connection string)

Is this what you were looking for? Let me know if I am off the mark and I will try to revise appropriately

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM