Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If in fact you cannot create either a custom DLL or a custom SSIS component, your only alternative will be to use <a href="http://msdn.microsoft.com/en-us/library/vstudio/system.reflection%28v=vs.100%29.aspx" rel="nofollow noreferrer">.NET reflection</a> in your consuming scripts to find the appropriate methods/properties and access them dynamically. </p> <p>That will be a significant amount of work, and the programming environment offered by SSIS isn't really conducive to it. If you really cannot deploy non-package code to your servers, I'd seriously rethink the architecture that needs that custom class.</p> <p>EDIT: Simple access wasn't as hard as I thought it might be. Assuming you have a package-level variable of type <code>Object</code> named "SomeObject", you could build a control flow like this: <img src="https://i.stack.imgur.com/DsjcH.png" alt="demonstration control flow for passing object variables"></p> <p>The code for SCR_SetVariables is:</p> <pre class="lang-cs prettyprint-override"><code>using System; using System.Data; using Microsoft.SqlServer.Dts.Runtime; using System.Windows.Forms; namespace ST_00e1230a50e6470e8324a14e9d36f6c7.csproj { [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")] public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase { #region VSTA generated code enum ScriptResults { Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success, Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure }; #endregion class SomeClass { public string Greeting { get; set; } public override string ToString() { return String.Format("My greeting is {0}", this.Greeting); } } public void Main() { SomeClass myClass = new SomeClass(); myClass.Greeting = "Hello, world!"; Dts.Variables["SomeObject"].Value = myClass; Dts.TaskResult = (int)ScriptResults.Success; } } } </code></pre> <p>and the code for SCR_ShowVariables is:</p> <pre class="lang-cs prettyprint-override"><code>using System; using System.Data; using Microsoft.SqlServer.Dts.Runtime; using System.Windows.Forms; using System.Reflection; namespace ST_eea68a39bda44e9d9afaa07d2e48fc0f.csproj { [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")] public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase { #region VSTA generated code enum ScriptResults { Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success, Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure }; #endregion public void Main() { object someObject = Dts.Variables["SomeObject"].Value; PropertyInfo getGreeting = someObject.GetType().GetProperty("Greeting"); string greeting = (string)getGreeting.GetValue(someObject, null); string msg = String.Format("someObject.Greeting = '{0}'", greeting); System.Windows.Forms.MessageBox.Show(msg); Dts.TaskResult = (int)ScriptResults.Success; } } } </code></pre> <p>This will show the following messagebox:</p> <p><img src="https://i.stack.imgur.com/bUIfy.png" alt="resulting messagebox displaying &quot;Hello, world!&quot;"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload