Quantcast
Channel: Microsoft SQL Server Community Samples: Integration Services
Viewing all articles
Browse latest Browse all 582

New Post: Setting Execute SQL Task Connection Manager

$
0
0
I found out what's wrong. The EzExecuteSqlTask's Connection property's setter is actually incorrectly coded. Current implementation is as follows.
public EzConnectionManager Connection
{
    get { return m_connection; }
    set 
    {
        if (value == null)
        {
            throw new ArgumentNullException("Connection value");
        }
        if (value.CM.CreationName != "OLEDB")
        {
            throw new IncorrectAssignException(string.Format("Cannot assign {0} connection to EzExecSqlTask", value.CM.CreationName));
        }
        (host.InnerObject as ExecuteSQLTask).Connection = value.Name;
        m_connection = value;
    }
}
The problem is with the line
(host.InnerObject as ExecuteSQLTask).Connection = value.Name;
First of all the cast can't be done that way (and shouldn't since NullReferenceException will be thrown and it isn't dealt with). Secondly the line should be (or similar)
host.Properties["Connection"].SetValue(host, value.Name);

Viewing all articles
Browse latest Browse all 582

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>