0
请看下面的一段代码。它只接受ADO.NET连接类型,我想要做的就是使它适用于OLEDB。换句话说,如果ConnectionManager提供了OLEDB类型的连接,它不应该失败。它只会使用ADO.NET或OLEDB连接(我不同时寻找它们)。连接管理器接受ADO.NET或OLEDB连接类型
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
private SqlConnection sqlConnection;
public override void AcquireConnections(object transaction)
{
if (ComponentMetaData.RuntimeConnectionCollection[0].ConnectionManager != null)
{
ConnectionManager cm = Microsoft.SqlServer.Dts.Runtime.DtsConvert.GetWrapper(ComponentMetaData.RuntimeConnectionCollection[0].ConnectionManager);
ConnectionManagerAdoNet cmado = cm.InnerObject as ConnectionManagerAdoNet;
if (cmado == null)
throw new Exception("The ConnectionManager " + cm.Name + " is not an ADO.NET connection.");
sqlConnection = cmado.AcquireConnection(transaction) as SqlConnection;
sqlConnection.Open();
}
}
对此的任何帮助表示赞赏!谢谢。