![](/img/trans.png)
[英]Why does the SSIS package fail when deployed to Integration Services Catalogs but runs fine on Visual studio?
[英]SSIS Package runs fine in Visual Studio but fails when run manually on the deployed box
我有一個腳本任務,將某些傳入的對象從一個服務器傳輸到另一個服務器。 這是代碼
public void Main()
{
try
{
string schemaName = Dts.Variables["$Package::SchemaName"].Value.ToString();
string objectName = Dts.Variables["$Package::ObjectName"].Value.ToString();
//object rawETLConnection = Dts.Connections["etl"].AcquireConnection(Dts.Transaction);
//Server etlServer = (Server)rawETLConnection;
Server etlServer = new Server("ciesqldeva04");
Database etlDB;
etlDB = etlServer.Databases["sell_side_content"];
//object rawReportingConnection = Dts.Connections["reporting"].AcquireConnection(Dts.Transaction);
//Server reportingServer = (Server)rawReportingConnection;
Server reportingServer = new Server("ciesqldeva05");
Transfer xfr;
xfr = new Transfer(etlDB);
xfr.DestinationServer = reportingServer.Name;
xfr.DestinationDatabase = "sell_side_content";
xfr.DropDestinationObjectsFirst = true;
xfr.CopyAllObjects = false;
xfr.CopyData = true;
xfr.CopySchema = true;
xfr.Options.DriAll = true;
xfr.ObjectList.Add(etlDB.Tables[objectName, schemaName]);
xfr.TransferData();
}
catch (SmoException smoex)
{
Dts.Events.FireError(120, " SMO - TransferObjects.dtsx", smoex.Message, "", 0);
}
catch (Exception ex)
{
Dts.Events.FireError(120,"Non SMO - TransferObjects.dtsx",ex.Message,"",0);
}
Dts.TaskResult = (int)ScriptResults.Success;
}
當我通過Visual Studio 2012運行它時工作正常。但是當我將它部署到盒子上並通過右鍵單擊SSMS中的包名並運行它來運行它時,它會失敗並顯示“使用SMO傳輸對象:錯誤:錯誤在傳輸數據時發生。有關詳細信息,請參閱內部異常。“
我還將腳本轉換為控制台應用程序並在我之前部署包並通過終端運行它的盒子上運行它,它能夠成功傳輸,因此它看起來不像丟失DLL的問題。
這是該控制台應用程序的代碼
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Management.Smo;
using System.Collections.Specialized;
using System.Collections;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Server etlServer = new Server("ciesqldeva04");
Database etlDB;
etlDB = etlServer.Databases["sell_side_content"];
//object rawReportingConnection = Dts.Connections["reporting"].AcquireConnection(Dts.Transaction);
//Server reportingServer = (Server)rawReportingConnection;
Server reportingServer = new Server("ciesqldeva05");
try
{
Transfer xfr;
xfr = new Transfer(etlDB);
xfr.DestinationServer = reportingServer.Name;
xfr.DestinationDatabase = "sell_side_content";
xfr.DropDestinationObjectsFirst = true;
xfr.CopyAllObjects = false;
xfr.CopyData = true;
xfr.CopySchema = true;
xfr.Options.DriAll = true;
xfr.ObjectList.Add(etlDB.Tables["award_sector", "people"]);
xfr.TransferData();
}
catch (SmoException smoex)
{
Console.WriteLine("This is an SMO Exception");
//Display the SMO exception message.
Console.WriteLine(smoex.Message);
//Display the sequence of non-SMO exceptions that caused the SMO exception.
}
}
}
}
我嘗試了各種各樣的事情但沒有成功。 任何幫助將非常感激。
PS我在SQL Server 2012上運行它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.