0
我在SSIS中使用腳本任務。在我ScriptMain.cs,我有以下代碼:從新類訪問Dts.Connections
namespace Program
{
[System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
public void Main()
{
int connectionCount = GetConnectionCount();
NewClass n = new NewClass();
connectionCount = n.GetConnectionCount2();
}
public int GetConnectionCount()
{
return Dts.Connections.Count;
}
}
}
而且在我的NewClass:
namespace Program
{
public class NewClass : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
{
public int GetConnectionCount2()
{
return Dts.Connections.Count;
}
}
}
當我GetConnectionCount()方法執行,我能帶回的計數次數SSIS連接管理器中的連接。然而,當我嘗試運行GetConnectionCount2()時,無論我添加/嘗試什麼引用,都會收到System.NullReferenceException錯誤。
我怎樣才能訪問Dts.Connections從一個新的類?
你能提供一個例子嗎?那麼我可以將你的標記作爲答案。 –
你去了,例子是在答案編輯。 –