Script task destination

hi
i have 1 ssis variable which i am trying to use in my script task,but when i run its throwing an error.
how to use curentdate here.i am passing as a read only in script task
    fileContents.AppendLine(String.Format("ABC" & Dts.Variables("CurentDate").Value.ToString()))
        fileContents.Append(File.ReadAllText(Dts.Connections("Destination").ConnectionString))
        File.WriteAllText(finalFile, fileContents.ToString())

I would use something like this to
add a footer to an existing file:
string filePath = Dts.Connections["myFlatFile"].AcquireConnection(Dts.Transaction).ToString();
using (StreamWriter sw = File.AppendText(filePath))
sw.WriteLine(Dts.Variables["User::yourVariable"].Value.ToString());
You could add some more formating to the string... but you could also add an expression to a variable to create the right string/footer.
Please mark the post as answered if it answers your question | My SSIS Blog:
http://microsoft-ssis.blogspot.com |
Twitter

Similar Messages

  • Script task error during the creation of partition by reading a table and using AMO - SSAS 2012

    Hi,
    I need to create SSAS (tabular) and process partitions in an authomatic manner. Moreover, the partitioning is respect to a category, an year and a month.
    Category, year and month are resident on a table to read to create the SSAS partitions.
    So, in a SSIS pkg:
    a. I've created a data flow task to read the SQL Server table having category, year and month data,
    b. I've connected the output of the ole db source as the input for a recordset destination, associated to an object variable,
    c. I've used a for each loop container (ado enumerator) specifying the object variable and three variables, for category, year and month,
    d. inside the for each loop container I've created a script task using AMO (visual basic) to control for any existing partitions, if not presents to create the new ones and then to process them.
    For the first iteration, a new partition has been created and processed successfully, but then, for other category, year and month values the script task fails. I've controlled the code many times and I've tried to put returning messageboxes but I've found
    anything. The error is a generic one and no other info are returned.
    Well, any suggests to me in order to solve this issue, please?
    Many thanks

    Hi, thanks, I've solved adding to the code end the SSAS server connection termination.
    Bye

  • SSIS PACKAGE MIGRATION FROM 2005 to 2008 - Script task/component errors

    HI All,
    We have to migrate ssis packages (about 300) from ssis 2005 to 2008 .
    1. I understand that the major concern is regarding the script component/tasks.
    I searched a lot about this and also consulted with many friends , all of them are aware of this issue but not able to provide what could be the issues and the solution.
    Can some one help me with the common script issues that can happen during migration and the solution for the same.
     2. I do have one more question.
    As per my understanding given in the below link 
    http://blogs.msdn.com/b/mattm/archive/2008/03/21/package-upgrade-wizard.aspx
    there is this part which says ... 
    Once the packages have been chosen, the next page asks you to pick the output location. This can be:
    Same as the source location
    File System
    SSIS Service (Package Store)
    SQL Server 
    Does this mean I can deploy in sql server directly on fly while upgrading ?
    Any help highly appreciated .
    Regards
    Praveen..

    Hi Praveen,
    Question 1: The error may occur if there are duplicate input columns in the Script Task/Component or the current user cannot access the C:\Windows\Temp directory. Except for the link provided by SanBhaumik, you can also refer to the following
    threads:
    http://www.sqlservercentral.com/Forums/Topic811208-148-1.aspx 
    http://social.technet.microsoft.com/Forums/sqlserver/en-US/5c11eb57-59d6-4f81-bfdc-13bd6489a0ac/sql-server-2008-ssis-package-script-component-error?forum=sqlintegrationservices 
    Question 2: We can directly save the package to the File System, SSIS Package Store, or SQL Server by selecting the proper destination during the package upgrade. However, this operation is not equal to the package install operation identically.
    For example, if we have enabled package configurations for a package, the package configurations won’t be upgraded or installed during the package upgrade.
    Regards,
    Mike Yin
    TechNet Community Support

  • Script Task - convert excel to txt

    Hi,
    I have an .xls file in a shared folder. How can we convert this file into a txt file and save it with a different name in the same or different folder.
    Thanks
    Syed Faiz

    I’m not sure why you want to do that and your requirements but you can do this with a simple File System task instead of Script task.
    Create a variable (strDest) of String type and provide the value - C:\SSISPackages\First\Forums\ExcelToTxt.txt
    C:\SSISPackages\First\Forums\ is your destination path and ExcelToTxt is your Excel file name.
    Drop a File System task
    Select the Operation – Copy file
    Source connection – Provide the connection to your Excel file
    Destination connection – Provide the connection to your Destination folder (like - C:\SSISPackages\First\Forums\ i.e. where you want to copy the Excel file as Text file)
    Now, go to your Destination Connection properties > Expressions > Connection String
     > Select the variable – strDest as Expression
    Execute the package.
    Narsimha

  • Dynamic script task to copy data from one server table to another server table excluding Timestamp column ?

    I have two server TestSource and TestDestination . In both the tables I have common table like below. I would like to copy the data from TestSource server src_Table to TestDestination server  table dest_table
    excluding the column timestamp. This process I would like to achieve dynamically. Since I have 50 tables where I need to copy from source server to destination server.
    Rule : This needs to achieve using script task. Please help me to find the solution as it is very urgent requirement.
    Above rule is because No option to choose export wizard dynamic query option for linked server.
     --Source
    Table
    CREATE TABLE src_table
    a int,
    b int,
    c timestamp
    --Dest Table
    CREATE TABLE dest_table
    a int,
    b int,
    c timestamp
    Thank you in advance.
    Hari

    I have two server TestSource and TestDestination . In both the tables I have common table like below. I would like to copy the data from TestSource server src_Table to TestDestination server  table dest_table
    excluding the column timestamp. This process I would like to achieve dynamically. Since I have 50 tables where I need to copy from source server to destination server.
    Rule : This needs to achieve using script task. Please help me to find the solution as it is very urgent requirement.
    Above rule is because No option to choose export wizard dynamic query option for linked server.
     --Source
    Table
    CREATE TABLE src_table
    a int,
    b int,
    c timestamp
    --Dest Table
    CREATE TABLE dest_table
    a int,
    b int,
    c timestamp
    Thank you in advance.
    Hari

  • Error While executing a SSIS package which contains a script task through SQL Server Agent job

    Hi,
    I have a SQL Server 2012 SSIS package with a script task along with other tasks [data flow, execute sql tasks ]. When I manually executed the job through BIDS, its completed successfully. 
    Then I have automated the execution of the package through SQL Server Agent Job. But when I executed the package through SQL Agent job, it runs successfully for all the tasks except script task. When it comes to execute the Script Task, it is getting failed
    with the below error message.
    "Error: 2012-08-29 12:45:14.67
       Code: 0x00000001
       Source: Script Task 
       Description: Exception has been thrown by the target of an invocation.
    End Error
    DTExec: The package execution returned DTSER_FAILURE (1).
    Started:  12:45:10 PM
    Finished: 12:45:14 PM
    Elapsed:  4.353 seconds
    I have installed the SSIS on the 64-bit environment and SSIS service is running. Also I tried to run the job through 32 bit [job option] but I am getting the above error in all cases.
    Any help will be greatly appreaciated !
    Thanks,
    Navin
    - naveen.reddy

    Hi Arthur,
    My script task access the excel files in a network share, refresh them all and save them. When I execute the ETL manually or thru DTEXEC, it is executing successfully. I am facing the issue when I am executing thru SQL Agent Job only. Logging also showing
    the same error.
    "Error: 2012-08-23 12:45:14.67
       Code: 0x00000001
       Source: Script Task 
       Description: Exception has been thrown by the target of an invocation.
    End Error
    DTExec: The package execution returned DTSER_FAILURE (1).
    Started:  12:45:10 PM
    Finished: 12:45:14 PM
    Elapsed:  4.353 seconds
    - naveen.reddy

  • Script task fails to send mail to GMAIL

    Hi   guys ,
       I am new here and i am glad i that i am here.  I am working in a company  as SQL Server developer(T-sql), i am learning SSIS because  i wanted to move to data warehousing.
    I not familiar and i don't know any thing about  C#,  but i am learning SSIS on my own.
    I tried to send mail to gmail  using script task , both sender and receiver with same mail ID using variables which i tried using tutorial i found from the below link.
    [quote]http://www.codeproject.com/Articles/85172/Send-Email-from-SSIS-with-option-to-indicate-Email[/quote]
    but finally when i execute the task , it returns failure message and email is not sent.
    [quote]SSIS package "Send mail using script task.dtsx" starting.
    Error: 0x8 at Script Task: The script returned a failure result.
    Task failed: Script Task
    SSIS package "Send mail using script task.dtsx" finished: Success.
    [/quote]
    Below message taken from progress tab
    [quote]Error: The script returned a failure result.[/quote]
    Can you all please help me in  finding where i am going wrong? please check below code which i have used in script task.
    Microsoft SQL Server Integration Services Script Task
    Write scripts using Microsoft Visual C# 2008.
    The ScriptMain is the entry point class of the script.
    using System;
    using System.Data;
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    using System.Text.RegularExpressions;
    using System.Net.Mail;
    namespace ST_9bc84810a62a401aa44ddd905bcd369d.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
    The execution engine calls this method when the task executes.
    To access the object model, use the Dts property. Connections, variables, events,
    and logging features are available as members of the Dts property as shown in the following examples.
    To reference a variable, call Dts.Variables["MyCaseSensitiveVariableName"].Value;
    To post a log entry, call Dts.Log("This is my log text", 999, null);
    To fire an event, call Dts.Events.FireInformation(99, "test", "hit the help message", "", 0, true);
    To use the connections collection use something like the following:
    ConnectionManager cm = Dts.Connections.Add("OLEDB");
    cm.ConnectionString = "Data Source=localhost;Initial Catalog=AdventureWorks;Provider=SQLNCLI10;Integrated Security=SSPI;Auto Translate=False;";
    Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
    To open Help, press F1.
    public void Main()
    string sSubject = "Test Subject";
    string sBody = "Test Message";
    int iPriority = 2;
    if (SendMail(sSubject, sBody, iPriority))
    Dts.TaskResult = (int)ScriptResults.Success;
    else
    //Fails the Task
    Dts.TaskResult = (int)ScriptResults.Failure;
    public bool SendMail(string sSubject, string sMessage, int iPriority)
    try
    string sEmailServer = Dts.Variables["sEmailServer"].Value.ToString();
    string sEmailPort = Dts.Variables["sEmailPort"].Value.ToString();
    string sEmailUser = Dts.Variables["sEmailUser"].Value.ToString();
    string sEmailPassword = Dts.Variables["sEmailPassword"].Value.ToString();
    string sEmailSendTo = Dts.Variables["sEmailSendTo"].Value.ToString();
    string sEmailSendCC = Dts.Variables["sEmailSendCC"].Value.ToString();
    string sEmailSendFrom = Dts.Variables["sEmailSendFrom"].Value.ToString();
    string sEmailSendFromName = Dts.Variables["sEmailSendFromName"].Value.ToString();
    SmtpClient smtpClient = new SmtpClient();
    MailMessage message = new MailMessage();
    MailAddress fromAddress = new MailAddress(sEmailSendFrom, sEmailSendFromName);
    //You can have multiple emails separated by ;
    string[] sEmailTo = Regex.Split(sEmailSendTo, ";");
    string[] sEmailCC = Regex.Split(sEmailSendCC, ";");
    int sEmailServerSMTP = int.Parse(sEmailPort);
    smtpClient.Host = sEmailServer;
    smtpClient.Port = sEmailServerSMTP;
    System.Net.NetworkCredential myCredentials =
    new System.Net.NetworkCredential(sEmailUser, sEmailPassword);
    smtpClient.Credentials = myCredentials;
    message.From = fromAddress;
    if (sEmailTo != null)
    for (int i = 0; i < sEmailTo.Length; ++i)
    if (sEmailTo[i] != null && sEmailTo[i] != "")
    message.To.Add(sEmailTo[i]);
    if (sEmailCC != null)
    for (int i = 0; i < sEmailCC.Length; ++i)
    if (sEmailCC[i] != null && sEmailCC[i] != "")
    message.To.Add(sEmailCC[i]);
    switch (iPriority)
    case 1:
    message.Priority = MailPriority.High;
    break;
    case 3:
    message.Priority = MailPriority.Low;
    break;
    default:
    message.Priority = MailPriority.Normal;
    break;
    //You can enable this for Attachments.
    //SingleFile is a string variable for the file path.
    //foreach (string SingleFile in myFiles)
    // Attachment myAttachment = new Attachment(SingleFile);
    // message.Attachments.Add(myAttachment);
    message.Subject = sSubject;
    message.IsBodyHtml = true;
    message.Body = sMessage;
    smtpClient.Send(message);
    return true;
    catch (Exception ex)
    return false;
    Please help me resolve this guys ... THANKS IN ADVANCE

    Thank you very much for your reply @Elvis Long,
    Sorry for the late reply
    Actually, i am not trying or executing this task  from my office , but i am trying this at my home :( .
    sEmailPort has value 587 sEmailServer has smtp.gmail.com
    Can you please check whether this C# coding is correct or not ? because finally it gives error saying "Script
    Task: The script returned a failure result" 
    so can you please check this with your system and let me know what is wrong with this code
    Thanks in advance  

  • Getting error message when i am trying to update the excel file using script task in ssis package

    Hi Guys,
    I am getting error message when I am trying to update the excel. Please find the error messages as below
    Error at Update File [Update File]: Failed to compiled scripts contained in the package. Open the package in SSIS Designer and resolve the compilation errors.
    Error at Update File [Update File]: BC30002 - Type 'Microsoft.Office.Interop.Excel.Application' is not defined., ScriptMain.vb, 32, 32
    Error at Update File [Update File]: BC30002 - Type 'Microsoft.Office.Interop.Excel.Workbook' is not defined., ScriptMain.vb, 33, 25
    Error at Update File [Update File]: The binary code for the script is not found. Please open the script in the designer by clicking Edit Script button and make sure it builds successfully.
    Warning at Update File [Update File]: Found SQL Server Integration Services 2008 Script Task "ST_050fcae972904039b4f0fe59b7528ece" that requires migration!
    and the code that   I am using is
    Dell - Internal Use - Confidential
    ' Microsoft SQL Server Integration Services Script Task
    ' Write scripts using Microsoft Visual Basic
    ' The ScriptMain class is the entry point of the Script Task.
    Imports System
    Imports System.Data
    Imports System.Math
    Imports Microsoft.SqlServer.Dts.Runtime
    Imports Microsoft.Office.Interop.Excel
    <System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="",
    Description:="")> _
    <System.CLSCompliantAttribute(False)> _
    Partial
    Public Class ScriptMain
    Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    Enum ScriptResults
                Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
    Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    End Enum
    Public Sub Main()
            Dts.TaskResult = ScriptResults.Success
    'Dim proc As System.Diagnostics.Process
    'kill all instances of excel
    'For Each proc In System.Diagnostics.Process.GetProcessesByName("EXCEL")
    ' proc.Kill()
    'Next
    Dim excelnacomm As
    New Microsoft.Office.Interop.Excel.Application
    Dim wbnacomm As Microsoft.Office.Interop.Excel.Workbook
            wbnacomm = excelnacomm.Workbooks.Open("http://test.xlsx")(renamed
    the excel)
            wbnacomm.RefreshAll()
            wbnacomm.Save()
            wbnacomm.Close()
            excelnacomm.Quit()
            Runtime.InteropServices.Marshal.ReleaseComObject(excelnacomm)
    End Sub
    End
    Class
    Please let me know what could be the reason
    Smash126

    Download:
    Microsoft Office 2010: Primary Interop Assemblies Redistributable
    How to: Add or Remove References By Using the Add Reference Dialog Box  /  How to:
    Add and Remove References in Visual Studio (C#)
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • SSIS/Script Task/ VB 2008 Help Urgent...

    Hi Guys, 
    Simple Script Task, just rename Excel tab, here is my code...
    Imports System
    Imports System.Data
    Imports System.Math
    Imports Microsoft.SqlServer.Dts.Runtime
    Imports Microsoft.Office.Interop.Excel
    Imports System.IO
    Imports System.Text
    <System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _
    <System.CLSCompliantAttribute(False)> _
    Partial Public Class ScriptMain
    Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
    Enum ScriptResults
    Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
    Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
    End Enum
    Public Sub Main()
    Dts.VariableDispenser.LockForRead("User::FileName") ' File Name Variable
    Dim variablesList As Variables
    Dts.VariableDispenser.GetVariables(variablesList)
    'Dim SFileName As String
    'SFileName = variablesList("User::Filename").Value.ToString
    ' Dim vars As Variables 'New Added For Variable
    Dim oMissing As Object = System.Reflection.Missing.Value
    Dim xl As New Microsoft.Office.Interop.Excel.ApplicationClass()
    Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
    Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
    'Dts.VariableDispenser.LockForRead("Filename") 'New Added For Variable
    'Start For Variable
    'Dim File As String 'New Added For Variable
    'File = CType(vars("Filename").Value, String) 'New Added For Variable
    'MsgBox(Prompt:="Filename")
    'Dim laPath As String = "C:\Excel\ABC_dr_daily_lf_10-07-14.xls" 'My File Name
    Dim lapath As String = variablesList("User::FileName").Value.ToString 'New Added For Variable
    'MsgBox(Prompt:="Filename")
    xlBook = DirectCast(xl.Workbooks.Open(laPath, oMissing, oMissing, oMissing, oMissing, oMissing, _
    oMissing, oMissing, oMissing, oMissing, oMissing, oMissing, _
    oMissing, oMissing, oMissing), Workbook)
    xlSheet = DirectCast(xlBook.Worksheets.Item(1), Worksheet)
    xlSheet.Name = "data"
    xlBook.Save()
    xl.Application.Workbooks.Close()
    Dts.TaskResult = ScriptResults.Success
    End Sub
    End Class
    Finally I intalled MS Excel 2007 on my Dev Server. Here is the error that I am receiving....
    Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: 
    Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel._Application
    '. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}'
    failed due to the following error: Library not registered. 
    Please help me, this is very urgent.
    Thank You.

    No I didn't upgrade my SQL Server. OMG this error making me ehhhhhh. 
    Here I solve my problem. 
    RUN>REGEDIT>  and look for "Office.Interop.Excel" and delete the old version. I am using Excel 2007, 14.0. 
    It solve my Problem. 
    Thanks All.

  • Error in script task "The name 'file' does not exist in the current context"

    I am new to the c# scripting and SSIS come from PHP and Foxpro.
    I am using SSIS with a script task and I am getting am errror "The name 'file' does not exist in the current context" in the following code in the picture below: (See
    Why does the object named "file" go away after the first refrence to it?? How do I make it avaliable for the whole script??
         public void Main()
            String cFileInfo = null;
            DateTime dFTPFileDateTime;
       bool fireAgain = true;
                List<IRemoteFileInfo> fileList = (List<IRemoteFileInfo>)Dts.Variables["SFTPResult"].Value;
                foreach (IRemoteFileInfo file in fileList)
                    cFileInfo = file.Name + "|" +file.ModifiedTime +"|"+ file.Size;
                Dts.Events.FireInformation(1, "Name ", cFileInfo, "", 0, ref fireAgain);
                dFTPFileDateTime =
    file.ModifiedTime;
    << This is where the error is occuring. 
                Dts.TaskResult = (int)ScriptResults.Success;

    I think you forgot { and } after the loop... Or is that deliberately?
    Please mark the post as answered if it answers your question | My SSIS Blog:
    http://microsoft-ssis.blogspot.com |
    Twitter

  • Getting "Couldnot find Installable ISAM" error in script task in SSIS 2005 when trying to open (.xlsx files) Excel 2007-2010 files using VB script in Visual Studio 2005

    Hi Experts,
    I am trying to open .xlsx file in script task of SSIS 2005. I am using the 32-bit AccessDatabaseEngine driver with the Connection string as "Provider= Microsoft.ACE.OLEDB.12.0; Data Source=xlsx file path; Extended Properties="Excel 12.0 Xml;
    HDR=YES"" in script task.
    When we debug the VB script in Visual Studio 2005 and encounters the statement app.open() it throws the error "Couldn't find installable ISAM".
    My SQL server version is 2005 SP2 DE
    OS is Windows server 2003 EE SP2
    Could anyone please let me know what is the resolution for this error?
    Thanks and Regards,
    Adesh

    Hi Adesh,
    First, make sure the package runs in 32-bit runtime mode (set Run64BitRuntime property to False) because you are using the 32-bit ACE OLE DB Provider. If it is not the case, the issue may occur due to the corrupted drivers or registry keys. You can try to
    reinstall the 2007 Office System Driver: Data Connectivity Components as Arthur suggested.
    Regards,
    Mike Yin
    TechNet Community Support

  • Error while sending mail using script task in ssis 2008

    Hi,
        i am trying to send mail using ssis 2008 script task.for my requirement i am not able to use send mail task.
    code i have used is
    declared read only variables system::packagename
     Dim PACKAGE As String
            PACKAGE = Dts.Variables("System::PackageName").Value.ToString()
            Dim myHtmlMessage As MailMessage
            Dim mySmtpClient As SmtpClient
            myHtmlMessage = New MailMessage("[email protected]", "[email protected]", "PACKAGE STATUS", PACKAGE + "WAS FAILED")
         mySmtpClient = New SmtpClient("smtp.gmail.com")
            mySmtpClient.Credentials = New NetworkCredential("[email protected]", "mypassword")
            mySmtpClient.EnableSsl = True
            mySmtpClient.Port = 587
            mySmtpClient.Send(myHtmlMessage)
    error i am getting is
    Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1
    Authentication Required. Learn more at
       at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
       at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)
       at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
       at System.Net.Mail.SmtpClient.Send(MailMessage message)
       at ST_c121e07caaa94c21bb1355d4f753112f.vbproj.ScriptMain.Main()
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
       at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
       at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
    can any one tell me where i am going wrong

    also getting error as follows
    Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1
    Authentication Required. Learn more at
       at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
       at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from)
       at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
       at System.Net.Mail.SmtpClient.Send(MailMessage message)
       at ST_c121e07caaa94c21bb1355d4f753112f.vbproj.ScriptMain.Main()
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
       at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
       at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()

  • SSIS : Read Rows from an Object variable in SSIS Script Task which is looped many times.

    Hello All,
    Here is what I am trying to do...
    1. I am having two rows, one column in an Object Variable. (vLoopCountObj).
    2. I am having 30 Rows, 2 Columns in my second Object  Variable (vTableRowsObj)
    3. I have a FOR EACH LOOP which will run for number of rows in vLoopCountObj i.e 2 times here.
    4. I have a Script Task inside the FOR EACH LOOP to display all the rows of vTableRowsObj.
    5. When I execute, 30 Rows gets displayed only once. It will not display when the loop goes for second iteration. Please help me to display for second time.
    6. I have used below code to display the rows whithin the script task which is in SSIS dataflow task.
    Imports System
    Imports System.Data
    Imports System.Math
    Imports Microsoft.SqlServer.Dts.Runtime
    Imports System.Xml
    Imports System.Collections
    Imports System.Data.OleDb
    Public Class ScriptMain
    Public Sub Main()
    Dim oleDA As New OleDbDataAdapter
    Dim dt As New DataTable
    Dim col As DataColumn
    Dim row As DataRow
    Dim sMsg As String
    oleDA.Fill(dt, Dts.Variables("vTableRowsObj").Value)
    MsgBox("Number of Rows " + dt.Rows.Count.ToString())
    For Each row In dt.Rows
    For Each col In dt.Columns
    sMsg = sMsg & col.ColumnName & ": " & row(col.Ordinal).ToString & vbCrLf
    Next
    MsgBox(sMsg)
    sMsg = ""
    Next
    Dts.TaskResult = Dts.Results.Success
    End Sub
    End Class

    Hi Raj,
    It is verrrry interesting issue. I can also confirm that it doesnt loop again. I've made a simple test and figured that in the second loop even you fill the Dataadapter, record count is zero. Which brings me up to the idea: Somehow, after you read the object
    variable resultset, you can not read it again in the for each loop.
    Strange, probably a bug or a technical issue that is beyond my existing knowledge.
    I can provide a workaround. You can also loop in script task for first variable. (Nested loops)
    Let other members to examine and comment on this.
    Regards
    Onur
    (For others who also wants to test, here is my scenario
    Execute SQL Task 1:
    Query: SELECT 1 as Cnt UNION ALL SELECT 2 as Cnt
    Resultset: Full Resultset
    ResultSet Tab: Name: 0, Variable Name: User::vLoopCountObj;
    Execute SQL Task 2:
    Query: SELECT 1 as ColA, 2 as ColB UNION ALL SELECT 3 as ColA, 4 as ColB UNION ALL SELECT 5 as ColA, 6 as ColB
    Resultset: Full Resultset
    ResultSet Tab: Name: 0, Variable Name: User::vTableRowsObj;
    For Each Loop Container:
    Collection: Enum: ForEach ADO Enum
    Source Object: User::vLoopCountObj
    Enum Mode: Rows n the first Table
    Script Task:
    ReadOnlyVariables: User::vTableRowsObj
    Script Source:
    Imports System
    Imports System.Data
    Imports System.Math
    Imports Microsoft.SqlServer.Dts.Runtime
    Imports System.Xml
    Imports System.Collections
    Imports System.Data.OleDb
    Public Class ScriptMain
    Public Sub Main()
    Dim oleDA As New OleDbDataAdapter
    Dim dt As New DataTable
    Dim col As DataColumn
    Dim row As DataRow
    Dim sMsg As String
    oleDA.Fill(dt, Dts.Variables("vTableRowsObj").Value)
    Dts.Events.FireInformation(-1, "START!!!!!!!!!!!!!!", "START LOOP", "", 0, True)
    Dts.Events.FireInformation(1, "RowCount: ", dt.Rows.Count.ToString(), "", 0, True)
    For Each row In dt.Rows
    For Each col In dt.Columns
    sMsg = sMsg & col.ColumnName & ": " & row(col.Ordinal).ToString & vbCrLf
    Next
    Dts.Events.FireInformation(1, "Msg: ", sMsg, "", 0, True)
    sMsg = ""
    Next
    Dts.TaskResult = ScriptResults.Success
    End Sub
    End Class
    BI and ERP Senior Consultant @ Nexum Bogazici
    If it is, Please dont forget to mark as answered or at least vote as helpful if the post helps you in any ways.

  • Getting COM Component error while opening SSIS Script task.

    Hi All,
    While click on EDIT SCRIPT Button in script task it's not opening the script editing window.
    Getting below error message:
    "Error HRESULT E_FAIL has been returned from a call to a COM component. (EnvDTE)"
    We have added ADODB reference in script task.
    Thanks in advance, please give some suggestion.

    I am using SSIS 2008 R2.
    When I reload the package, script task visual studio opens first time, next time when I try to open script task visual studio from EDIT SCRIPT Button it gives below error:
    "Error HRESULT E_FAIL has been returned from a call to a COM component. (EnvDTE)"

  • Error While executing script task componnent

    Hi,
    I am using script task comp in  my package .script  written in script task comp
    ' Microsoft SQL Server Integration Services Script Task
    ' Write scripts using Microsoft Visual Basic
    ' The ScriptMain class is the entry point of the Script Task.
    Imports System
    Imports System.Data
    Imports System.Math
    Imports Microsoft.SqlServer.Dts.Runtime
    Imports System.IO
    Imports System.Collections
    Public Class clsCompareFileInfo
        Implements IComparer
        Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
            Dim File1 As FileInfo
            Dim File2 As FileInfo
            File1 = DirectCast(x, FileInfo)
            File2 = DirectCast(y, FileInfo)
            Compare = DateTime.Compare(File1.LastWriteTime, File2.LastWriteTime)
        End Function
    End Class
    <System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _
    <System.CLSCompliantAttribute(False)> _
    Partial Public Class ScriptMain
        Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
        Enum ScriptResults
            Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
            Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
        End Enum
        Public Sub Main()
            Dim dirinfo As DirectoryInfo
            Dim allFiles() As FileInfo
            dirinfo = New DirectoryInfo(Dts.Variables("gsLaddningsKatalogSokvag").Value.ToString)
            allFiles = dirinfo.GetFiles("*.txt")
            'Sortera filerna efter "senast ändrad" så den fil med äldst "ändrad datum" kommer att laddas först
            Array.Sort(allFiles, New clsCompareFileInfo)
            For Each fl As FileInfo In allFiles
                Dts.Variables("gsInFilNamnMedSokvag").Value = fl.FullName.ToString()
                Dts.Variables("gsInFilNamn").Value = Path.GetFileName(fl.FullName.ToString())
                Exit For
            Next
            Dts.TaskResult = ScriptResults.Success
        End Sub
    End Class
    Error which i ma getting while running..
    Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: The path is not of a legal form.
       at System.IO.Path.NormalizePathFast(String path, Boolean fullCheck)
       at System.IO.Path.NormalizePath(String path, Boolean fullCheck)
       at System.IO.Path.GetFullPathInternal(String path)
       at System.IO.DirectoryInfo..ctor(String path)
       at ST_338efd96a3e940b0b489d5b5000f3397.vbproj.ScriptMain.Main()
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
       at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture)
       at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()
    Please help.I am using sql server 2008R2 and visual studio 2008 BIDS.

    Hi,
    I am using script task comp in  my package .script  written in script task comp
    ' Microsoft SQL Server Integration Services Script Task
    ' Write scripts using Microsoft Visual Basic
    ' The ScriptMain class is the entry point of the Script Task.
    Imports System
    Imports System.Data
    Imports System.Math
    Imports Microsoft.SqlServer.Dts.Runtime
    Imports System.IO
    Imports System.Collections
    Public Class clsCompareFileInfo
        Implements IComparer
        Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
            Dim File1 As FileInfo
            Dim File2 As FileInfo
            File1 = DirectCast(x, FileInfo)
            File2 = DirectCast(y, FileInfo)
            Compare = DateTime.Compare(File1.LastWriteTime, File2.LastWriteTime)
        End Function
    End Class
    <System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _
    <System.CLSCompliantAttribute(False)> _
    Partial Public Class ScriptMain
        Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
        Enum ScriptResults
            Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success
            Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
        End Enum
        Public Sub Main()
            Dim dirinfo As DirectoryInfo
            Dim allFiles() As FileInfo
            dirinfo = New DirectoryInfo(Dts.Variables("gsLaddningsKatalogSokvag").Value.ToString)
            allFiles = dirinfo.GetFiles("*.txt")
            'Sortera filerna efter "senast ändrad" så den fil med äldst "ändrad datum" kommer att laddas först
            Array.Sort(allFiles, New clsCompareFileInfo)
            For Each fl As FileInfo In allFiles
                Dts.Variables("gsInFilNamnMedSokvag").Value = fl.FullName.ToString()
                Dts.Variables("gsInFilNamn").Value = Path.GetFileName(fl.FullName.ToString())
                Exit For
            Next
            Dts.TaskResult = ScriptResults.Success
        End Sub
    End Class
    Error which i ma getting while running..
    Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --->
    System.ArgumentException: The path is not of a legal form.
    Hi SR_MCTS, 
    The error message how the path is not of a legal form, please take a look at the highlight content in above message. Please try to use the following code:
    dirinfo = new DirectoryInfo(Dts.Variables["User::Local_Dir"].Value.ToString)
    Please ensure you have configure the vaild path for "Local_Dir" variable. For more information, you can take a look at the following thread:
    http://social.msdn.microsoft.com/forums/sqlserver/en-US/f073ecef-37ed-4a4c-bee6-d9ef66ff471d/filesystem-task-issue-ssis
    Regards,
    Elvis Long
    TechNet Community Support

Maybe you are looking for

  • Video Filters suddenly missing

    Started up Final Cut Pro 7 to start a new project, & found that a bunch of my filters are missing. I'm talking about the stiock filters that come with the program. Heaps of them seem to have vanished (there are now only 4 blur filters, & only 7 styli

  • Insert more than 4000 characters using sql plus

    I have a SQL script that creates a database. The problem is that some of the fields are longer than 4000 characters in the INSERT statement and Oracle doesn't seem to like it. The field is a clob and works fine in the application (i.e. I can insert m

  • Udp 發送大於64K資料產生錯誤 113 ,buffer不足

    大家好 我必須用UDP送出大於64k的封包而遇到緩衝區不足的錯誤 113.查過說明發現可藉由設定Wsock.dll method: setsockopt: optionnameo_sndbuf.的方式來增加windows UDP sending buffer,但是個錯誤還是未解.詳細內容我寫在英文的討論區中 http://forums.ni.com/t5/LabVIEW/Increase-UDP-sending-size-over-64k-bytes-and-get-error-113/td-p

  • Transport of Customizations from ECC 5.0 to ECC 6.0

    Hi, We have some customizations done in ECC 5.0, which we now want to implement in ECC 6.0 (Freshly Installed). Can we transport these customizations directly to ECC 6.0 (after checking the release notes to see if any functionality has changed betwee

  • Sync log in is blocked

    Hi I am trying to log in to firefox Sync. When it told me could not recognize my log in email as a valid, I tried to reset my password. And again the system state couldnt no recognaise my log in email. When restarted adn tried again, it said the "Att