0

i want to change the connection manager connection in ssis at run time so that it usese the connectionstring to connect and give me the result. but it is giving me this error i have set the delay validation property to false on the dataflow task???????

Error: 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.

ControlFlow control flow diagram

DataFlow dataflow diagram

connectionmanager http://www.dropbox.com/s/ozk4qynbelcr2n1/Untitled.png Dynamic Connection manager I have two one static and on dynamic

4

2 回答 2

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;
        }
    }

添加了优先约束条件

在此处输入图像描述

于 2013-08-06T07:09:46.377 回答
0

为此目的使用 ADO.NET 托管连接。我有类似的情况,只是创建了第二个连接管理器,其参数与 OLE DB 相同。

此外,不要更改脚本任务中的连接字符串,而是对连接管理器进行参数化(右键单击\参数化)。如果您需要一组以上的参数,请使用多个连接管理器。

使用托管的 conn 管理器,这将是您在代码中打开连接的方式:

SqlConnection GetConnection(string ConnMgrName)
{
    ConnectionManager cm = Dts.Connections[ConnMgrName];
    SqlConnection conn = (SqlConnection)cm.AcquireConnection(null);
    return conn;
}
于 2013-07-30T13:34:46.243 回答