Error: Error: Cannot load script for execution in Script task of SSIS.
hi, I am trying to open and close a excel source file My code: using System; using System.Data; using Microsoft.SqlServer.Dts.Runtime; using System.Windows.Forms; using Excel = Microsoft.Office.Interop.Excel; using System.Runtime.InteropServices; using Microsoft.Office.Interop.Excel; using System.Diagnostics; //using System.Management; using System.ComponentModel; Inside namespace: public Workbook xlWrkBook; public Workbooks xlWrkBooks; public Excel.Application xlApp = new Excel.Application(); public Sheets xlSheets; public Worksheet xlWrkSheet; public Worksheets xlWrkSheets; public string fileName = string.Empty; public void Main() { string InProcess = @"C:\Haroon\ETL\Pampurred Test\"; string Name = @"\\Cat Food.xls"; fileName = System.IO.Path.Combine(InProcess, Name); MessageBox.Show(fileName); OpenExcelWorkbook(fileName); MessageBox.Show("Excel opened"); CloseExcelWorkbook(); MessageBox.Show("Excel closed"); Dts.TaskResult = (int)ScriptResults.Success; } public void OpenExcelWorkbook(string fileName) { if (xlWrkBook == null) { xlWrkBooks = xlApp.Workbooks; xlWrkBook = xlWrkBooks.Open(fileName, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); xlSheets = xlWrkBook.Worksheets; } } public void CloseExcelWorkbook() { xlWrkBook.Save(); xlWrkBook.Close(false, Type.Missing, Type.Missing); } When i execute the script task i get error "Cannot load script for execution in Script task of SSIS." No variables passed. Help me to fix this issue. And also want to kill the excel process which i start by its ProcessID. Thanks in advance.
December 18th, 2010 1:08am

If you are trying to get data from the Excel file, why do you need a Script Component to do so? You can use this technique (Excel Source for example): http://blogs.techrepublic.com.com/datacenter/?p=205 If you are have some other intentions then try removing parts of the code until you get the exact place where the issue occurs. Or simply refer to this forum post: http://social.msdn.microsoft.com/Forums/en-US/sqlintegrationservices/thread/390b0812-e40e-4bab-9315-31710f6128c4/Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
December 18th, 2010 11:59pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics