Setting Execute SQL Task Connection Manager

Feb 13, 2013 at 9:32 AM
Hi,
How is setting execute SQL task connection manager supposed to be done using EzAPI? Setting the Connection property to an EzOleDbConnectionManager throws a NullReferenceException that originates from the EzExecuteSqlTask.ParameterBindings property.

Someone in this blog has been wondering the same a long time ago.
Feb 13, 2013 at 12:07 PM
Edited Feb 13, 2013 at 12:08 PM
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);