Problem Description
Currently, one cannot assign a variable as an OLEDB source using EzAPI. Assignment does not raise an error or exception but the associated property, SqlCommandVariable, is never set. This results in the generated package not having a source assigned which in turn results in the package raising an error of 'Accessing variable "" failed with error code 0xC0010001'
Reproduction Steps
The order of operations does not matter, both generate the same XML.
this.Source.AccessMode = AccessMode.AM_SQLCOMMAND_VARIABLE;
this.Source.DataSourceVariable = this.Variables["sourceQuery"].QualifiedName;
Resolution
I modified EzComponents.cs, line 1027 of changeset 65381 to modify the setter for the DataSourceVariable property. This necessitates the order of operations being
Set AccessMode to AM_SQLCOMMAND_VARIABLE
Assign variable
but I don't care as it works. Someonewill undoubtedly have a better understanding of what the proper holistic solution is. The AccessMode check was required because I had also used a variable in my destination and an access mode of AM_OPENROWSET_FASTLOAD_VARIABLE doesn't allow a property of SqlCommandVariable.
if (AccessMode == AccessMode.AM_SQLCOMMAND_VARIABLE)
{
m_comp.SetComponentProperty("SqlCommandVariable", value);
}
References
http://sqlsrvintegrationsrv.codeplex.com/discussions/286698
http://stackoverflow.com/questions/8916674/what-is-the-ezapi-equivalent-for-using-an-ole-db-source-command-from-variable