我想在运行时更改ssis中的连接管理器连接,以便它使用连接字符串连接并给我结果。但它给了我这个错误 我已在数据流任务???????
上将延迟验证属性设置为falseError: 0xC0202009 at Package, Connection manager "LHRPC-00916.fnp_scenter_test": SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80040E21.
Error: 0xC020801C at Data Flow Task, OLE DB Source [1]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager "LHRPC-00916.fnp_scenter_test" failed with error code 0xC0202009. There may be error messages posted before this with more information on why the AcquireConnection method call failed.
Error: 0xC0047017 at Data Flow Task, SSIS.Pipeline: component "OLE DB Source" (1) failed validation and returned error code 0xC020801C.
Error: 0xC004700C at Data Flow Task, SSIS.Pipeline: One or more component failed validation.
Error: 0xC0024107 at Data Flow Task: There were errors during task validation.
控制流程图
数据流图
connectionmanager http://www.dropbox.com/s/ozk4qynbelcr2n1/Untitled.png 动态连接管理器我有两个静态和动态
答案 0 :(得分:0)
为此目的使用ADO.NET托管连接。我有类似的情况,只是创建了第二个连接管理器,其参数与OLE DB相同。
此外,不是更改脚本任务中的连接字符串,而是参数化连接管理器(右键单击\ parametrize)。如果您需要多个参数集,请使用多个连接管理器。
使用托管conn管理器,这将是您在代码中打开连接的方式:
SqlConnection GetConnection(string ConnMgrName)
{
ConnectionManager cm = Dts.Connections[ConnMgrName];
SqlConnection conn = (SqlConnection)cm.AcquireConnection(null);
return conn;
}
答案 1 :(得分:0)
在脚本任务中写下以下脚本
public void CheckConnectionString()
{
try
{
if (Dts.Connections["DynamicConnection"] != null)
{
ConnectionManager ConMGr = Dts.Connections["DynamicConnection"];
ConMGr.AcquireConnection(null);
Dts.Variables["ConnectionAvailable"].Value = true;
}
}
catch (Exception ex)
{
Dts.Variables["ConnectionAvailable"].Value = false;
Dts.Variables["ErrorDescription"].Value = ex.Message;
}
finally
{
Dts.TaskResult = (int)ScriptResults.Success;
}
}
添加了优先约束条件