請問各位,寫了一支程式主要是要連接資料庫後新增資料表並插入資料,之後用SSIS轉出excel報表。
測試過在本機使用都沒問題,但是到別台電腦上安裝就碰到許多問題:
程式碼如下(省略冗長SQL語法):
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using QC = System.Data.SqlClient;
using System.Diagnostics;
using Microsoft.SqlServer.Dts.Runtime;
private void button1_Click(object sender, EventArgs e)
{
SqlConnection SqlSvrCon1 = new SqlConnection(strCon);
SqlSvrCon1.Open();
SqlCommand objCommand1 = new SqlCommand(SQL1, SqlSvrCon1);
objCommand1.CommandTimeout = 120;
objCommand1.ExecuteNonQuery();
SqlSvrCon1.Close();
string pkgLocation;
Package pkg;
Microsoft.SqlServer.Dts.Runtime.Application app;
DTSExecResult pkgResults;
pkgLocation =
@"C:\20190412001\20190412001\export\Package1.dtsx";
app = new Microsoft.SqlServer.Dts.Runtime.Application();
pkg = app.LoadPackage(pkgLocation, null);
pkgResults = pkg.Execute();
}
↑原本有兩個專案,但是我把另一個專案(Integration Services Project)SSIS封裝的.dtsx檔拉過來執行,不曉得有沒有影響在非本機上的執行
到其他電腦上便會發生錯誤
↑將C:\Windows\Microsoft.NET\assembly\GAC_32***(和64)***\Microsoft.SqlServer.DTSRuntimeWrap的資料拉過去後變成如下錯誤
Microsoft.SqlServer.Dts.Runtime.DtsComException: An Integration Services class cannot be found. Make sure that Integration Services is correctly installed on the computer that is running the application. Also, make sure that the 64-bit version of Integration Services is installed if you are running a 64-bit application. ---> System.Runtime.InteropServices.COMException: 擷取元件 (CLSID 為 {4F0FC44B-C99C-441D-B86A-D60D7E22143D}) 的 COM Class Factory 失敗,因為發生下列錯誤: 80040154 類別未登錄 (發生例外狀況於 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))。
於 Microsoft.SqlServer.Dts.Runtime.Application..ctor()
↑這支程式之後是在使用者電腦上使用的,希望不要安裝太多程式(已經要Framwork),但是目前測試的筆電開啟官網的SSDT-Setup-CHT.exe也沒有反應,下載舊版的SSDT也發生錯誤無法安裝,所以想知道針對使用SSIS匯出報表需要那些元件在電腦上才可以正常執行
非常感謝
參考來源:https://social.msdn.microsoft.com/Forums/sqlserver/en-US/dc7c3351-b07f-4339-b61e-f214e4529436/integration-services-class-cannot-be-found-ssis-sql-server-2014?forum=sqlintegrationservices