Using Script Task to rename an excel sheet.

I'm trying to use an SSIS Script Task to rename an excel sheet.
I've found several code samples on the net but most don't compile correctly and my knowledge of VB.net or C# isin't strong enough to fix the issues. I suspect they work but not for SSIS 2012 possibly.
Found the sample below which shows no errors at design time, but fails with an Invocation error so I'm unable to even trap what the error is to help in resolving the issue.
Does anyone have any sample code that they KNOW WORKS in SSIS 2012 or can see what the problem is ?
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
        Dim laPath As String = "C:\Test.xlsx"
        Try
            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 = "Sheet1"
            xlBook.Save()
            xl.Application.Workbooks.Close()
            Dts.TaskResult = ScriptResults.Success
        Catch ex As Exception
            MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK)
            Dts.Events.FireError(1, ex.TargetSite.ToString(), ex.Message.ToString(), "", 0)
            Dts.TaskResult = ScriptResults.Failure
        End Try
Thanks.

Why do you need a script task for this? You can define the sheetname at the time of data transfer itself by creating a new sheet with required name
See this as an example
http://visakhm.blogspot.in/2013/09/exporting-sqlserver-data-to-multiple.html
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My Wiki User Page
My MSDN Page
My Personal Blog
My Facebook Page

Similar Messages

  • How can apply configure file in ssis by using script task ?

    I had  two config file in ssis
     1. config file as per QA
    2. config file as per Production
     I think apply dynamically by using script task for above file (acc to server)
    How can I apply in script task for config file path in C# script
    any one provide Helpful code ??
    Thanks

    I applied script Task  with below code :
    public void Main()
    //User::Config,User::Config_Pd,User::Config_QA
    Application App = new Application();
    Package Pack = new Package();
    DTSExecResult pkgResults;
    string strPackageName;
    string filename = "";
    string configvalue;
    configvalue = Dts.Variables["Config"].Value.ToString();
    strPackageName = Directory.GetCurrentDirectory().ToString() + "\\Excel Reports from Remittance advice\\Child.dtsx";
    try
    Pack = App.LoadPackage(strPackageName, null);
    if (Pack != null)
    if (configvalue == "DEV")
    filename = Dts.Variables["Config_QA"].Value.ToString();
    else if (configvalue == "PROD")
    filename = Dts.Variables["Config_Pd"].Value.ToString();
    else
    Dts.TaskResult = (int)ScriptResults.Failure;
    System.Windows.Forms.MessageBox.Show("Unable to bind the XML Configurations");
    return;
    } System.Windows.Forms.MessageBox.Show("Config:"+filename);
    Pack.ImportConfigurationFile(@filename);
    Pack.EnableConfigurations = true;
    Pack.Configurations.Add();
    App.SaveToXml(strPackageName, Pack, null)
    pkgResults = Pack.Execute(); //Pack.Execute();
    System.Windows.Forms.MessageBox.Show("Results:" + pkgResults.ToString());
    Dts.TaskResult = (int)ScriptResults.Success;
    But ouput in ssis showing as
    But some thing missed in code  plz help me ...

  • How to load data into table Using Script Task

    We have a directory/folder where we have a file. We need to insert the File Created Date , File Name , Extension into the database table of Sql server by using Script Task.
    So could you please suggest , how to frame the connection string , fetch the file details and insert the data into the database table using Script Task of SSIS 2008

    You can achieve it as follows using standard script task
    1. Add a ForEachLoop container to point to your directory to iterate though the files. Add a variable of type string inside loop to get file name of each file it iterates. Choose option Filename and extension. Add a variable to just store extension part
    (FileExtension), set EValuateAsExpression true for it and give expression as below
    SUBSTRING(@[User::FileName],FINDSTRING(@[User::FileName],".",1)+1,LEN(@[User::FileName]))
    2. Add a script task inside loop and pass filename variable as a read only variable to it. Crete a new variable to get creationdate and pass it as ReadWrite. Inside write code as below
    Public Sub Main()
    ' Add your code here
    Dim f As New System.IO.FileInfo(Dts.Variables("FileName").Value.ToString())
    Dts.Variables("FileCreatedDate").Value = f.CreationTime
    Dts.TaskResult = ScriptResults.Success
    End Sub
    3. Add a Exec SQL Task after Script task inside loop and give a query like below
    INSERT INTO TableName (FileName,CreatedDate,Extension)
    VALUES(?,?,?)
    and in parameter tab map the parameter placeholders 0,1 and 2 to @[User::FileName],@[User::FileCreatedDate] & @[User::FileExtension] variables
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • 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]

  • 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()

  • Unable to initiate BPM process despite using script task

    Hi,
    I've created a BPMN process which I want to initiate through a script task - I followed the steps given in section 3.7 of the following doc -
    https://stbeehive.oracle.com/content/dav/st/HP%20personal%20workspace/Public%20Documents/BPMN_03_SalesQuote_Implementation.pdf
    but after deploying this process, when I go to BPM workspace using my user's login, I don't see my BPM process under list of applications. What could be wrong?
    Thanks,
    Harsh

    Hi Lavanya,
    Could you please tell me how you resolved. I am also getting same error.
    com.sap.glx.adapter.api.AdapterException: Process start failed due to TransitionException
    Thanks in advance.
    cheers,
    dev

  • Bulk Insert using Script Task in SSIS

    Hi guys,
    Please I have about 300Million rows of data I want to load from a remote SQL server into another SQL server. The problem is that the data takes forever to load and I have a time line.
    I was wondering if there is a way in can do bulk insert for this or maybe if I can get a code that I can use to load the data faster.
    Please I really need your help as my job depends on this.
    me

    CREATE TABLE [dbo].[post_tran](
    [post_tran_id] [bigint] NOT NULL,
    [post_tran_cust_id] [bigint] NOT NULL,
    [settle_entity_id] [dbo].[POST_ID] NULL,
    [batch_nr] [int] NULL,
    [prev_post_tran_id] [bigint] NULL,
    [next_post_tran_id] [bigint] NULL DEFAULT ((0)),
    [sink_node_name] [dbo].[POST_NAME] NULL,
    [tran_postilion_originated] [dbo].[POST_BOOL] NOT NULL,
    [tran_completed] [dbo].[POST_BOOL] NOT NULL,
    [message_type] [char](4) NOT NULL,
    [tran_type] [char](2) NULL,
    [tran_nr] [bigint] NOT NULL,
    [system_trace_audit_nr] [char](6) NULL,
    [rsp_code_req] [char](2) NULL,
    [rsp_code_rsp] [char](2) NULL,
    [abort_rsp_code] [char](2) NULL,
    [auth_id_rsp] [varchar](10) NULL,
    [auth_type] [numeric](1, 0) NULL,
    [auth_reason] [numeric](1, 0) NULL,
    [retention_data] [varchar](999) NULL,
    [acquiring_inst_id_code] [varchar](11) NULL,
    [message_reason_code] [char](4) NULL,
    [sponsor_bank] [char](8) NULL,
    [retrieval_reference_nr] [char](12) NULL,
    [datetime_tran_gmt] [datetime] NULL,
    [datetime_tran_local] [datetime] NOT NULL,
    [datetime_req] [datetime] NOT NULL,
    [datetime_rsp] [datetime] NULL,
    [realtime_business_date] [datetime] NOT NULL,
    [recon_business_date] [datetime] NOT NULL,
    [from_account_type] [char](2) NULL,
    [to_account_type] [char](2) NULL,
    [from_account_id] [varchar](28) NULL,
    [to_account_id] [varchar](28) NULL,
    [tran_amount_req] [dbo].[POST_MONEY] NULL,
    [tran_amount_rsp] [dbo].[POST_MONEY] NULL,
    [settle_amount_impact] [dbo].[POST_MONEY] NULL,
    [tran_cash_req] [dbo].[POST_MONEY] NULL,
    [tran_cash_rsp] [dbo].[POST_MONEY] NULL,
    [tran_currency_code] [dbo].[POST_CURRENCY] NULL,
    [tran_tran_fee_req] [dbo].[POST_MONEY] NULL,
    [tran_tran_fee_rsp] [dbo].[POST_MONEY] NULL,
    [tran_tran_fee_currency_code] [dbo].[POST_CURRENCY] NULL,
    [tran_proc_fee_req] [dbo].[POST_MONEY] NULL,
    [tran_proc_fee_rsp] [dbo].[POST_MONEY] NULL,
    [tran_proc_fee_currency_code] [dbo].[POST_CURRENCY] NULL,
    [settle_amount_req] [dbo].[POST_MONEY] NULL,
    [settle_amount_rsp] [dbo].[POST_MONEY] NULL,
    [settle_cash_req] [dbo].[POST_MONEY] NULL,
    [settle_cash_rsp] [dbo].[POST_MONEY] NULL,
    [settle_tran_fee_req] [dbo].[POST_MONEY] NULL,
    [settle_tran_fee_rsp] [dbo].[POST_MONEY] NULL,
    [settle_proc_fee_req] [dbo].[POST_MONEY] NULL,
    [settle_proc_fee_rsp] [dbo].[POST_MONEY] NULL,
    [settle_currency_code] [dbo].[POST_CURRENCY] NULL,
    [icc_data_req] [text] NULL,
    [icc_data_rsp] [text] NULL,
    [pos_entry_mode] [char](3) NULL,
    [pos_condition_code] [char](2) NULL,
    [additional_rsp_data] [varchar](25) NULL,
    [structured_data_req] [text] NULL,
    [structured_data_rsp] [text] NULL,
    [tran_reversed] [char](1) NULL DEFAULT ((0)),
    [prev_tran_approved] [dbo].[POST_BOOL] NULL,
    [issuer_network_id] [varchar](11) NULL,
    [acquirer_network_id] [varchar](11) NULL,
    [extended_tran_type] [char](4) NULL,
    [ucaf_data] [varchar](33) NULL,
    [from_account_type_qualifier] [char](1) NULL,
    [to_account_type_qualifier] [char](1) NULL,
    [bank_details] [varchar](31) NULL,
    [payee] [char](25) NULL,
    [card_verification_result] [char](1) NULL,
    [online_system_id] [int] NULL,
    [participant_id] [int] NULL,
    [opp_participant_id] [int] NULL,
    [receiving_inst_id_code] [varchar](11) NULL,
    [routing_type] [int] NULL,
    [pt_pos_operating_environment] [char](1) NULL,
    [pt_pos_card_input_mode] [char](1) NULL,
    [pt_pos_cardholder_auth_method] [char](1) NULL,
    [pt_pos_pin_capture_ability] [char](1) NULL,
    [pt_pos_terminal_operator] [char](1) NULL,
    [source_node_key] [varchar](32) NULL,
    [proc_online_system_id] [int] NULL,
    [from_account_id_cs] [int] NULL,
    [to_account_id_cs] [int] NULL,
    [pos_geographic_data] [char](5) NULL,
    [payer_account_id] [char](5) NULL,
    [cvv_available_at_auth] [varchar](30) NULL,
    [cvv2_available_at_auth] [varchar](30) NULL
    ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
    GO
    me

  • Problem with Script Task formatting excel

    Hi Experts,
    I am creating a package and using Script task to format one excel dimension file, now the problem is if I execute the package from BIDS designer with static values then the package executes fine with excel file formatted perfectly fine but if I execute same package in BPC via Data manager with values used from variables it gives error on script task message:
    "Description = System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x800A03EC): Microsoft Office Excel cannot access the file 'E:\PC_MS\Data\Webfolders\CDNPLAN\AdminApp\Stage\Employee.xls'. There are several possible reasons:
    u2022 The file name or path does not exist.
    u2022 The file is being used by another program.
    u2022 The workbook you are trying to save has the same name as a currently open workbook.
    at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
    at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
    at ScriptTask_2921447fa19c44dfae73d5370828ba94.vbproj.ScriptMain.Main()
    Now to crosscheck I commented the dynamic variables from the code and used same static values with Data manager as they are in BIDS but it didn't help, please find the code below and help me in solving this problem or just give me some clue to come out if this:
    Thanks & Regards,
    Rohit
    Code
    Public Sub Main()
              ' Add your code here
            'Dim FileName As String = Dts.Variables("MYWEBFOLDERS").Value & Dts.Variables("MYAPPSET").Value & "\AdminApp\Stage\" & Dts.Variables("MYDIMNAME").Value & ".xls" This I commented as it was using dynamic variables
            Dim FileName As String = "E:\PC_MS\Data\Webfolders\CDNPLAN\AdminApp\Stage\Employee.xls"
        Dim WB As Object ' Workbook
        Dim WS As Object 'Worksheet
        Dim W As Object 'Window
        Dim XL As Object 'Application
        XL = CreateObject("Excel.Application")
        XL.DisplayAlerts = False
        ' Open the workbook
        WB = XL.Workbooks.Open(FileName)
        ' WB = GetObject(FileName)
        '    XL = WB.Parent
        '    XL.DisplayAlerts = False
        WS = WB.Worksheets(1)
        W = WB.Windows(WB.Name)
        ' Change the name of the worksheet to MEMBERS
        WS.Name = "MEMBERS"
        ' Set up the split and freeze the panes
        W.SplitRow = 1
        W.SplitColumn = 1
        W.Split = True
        W.FreezePanes = True
        ' Make it visible
        W.Visible = True
        ' Replace *ID column header with ID
        Dim Row1 As Object
        Row1 = WS.UsedRange.Rows("1:1")
        Dim I As Integer
        For I = 1 To Row1.Columns.Count
          If Row1.Cells(I, 1).Value = "*ID" Then
            Row1.Cells(I, 1).value = "ID"
            Exit For
          End If
        Next
        ' Paste Values
        WS.UsedRange.NumberFormat = "@"
        WS.UsedRange.Value = WS.UsedRange.Value
        ' Change the font of everything to Arial,9
        With WS.Cells.Font
          .Name = "Arial"
          .Size = 9
        End With
        ' Format the top row to be bold and orange
        With WS.Rows("1:1")
          .Font.Bold = True
          .Interior.ColorIndex = 44 'orange
        End With
        ' Auto-fit all the columns
        WS.Cells.EntireColumn.AutoFit()
        ' Convert to Excel format
        Const xlNormal = -4143
        WB.Parent.DisplayAlerts = False
        WB.SaveAs(FileName:=FileName, FileFormat:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False)
            ' Close and save changes
            WS = Nothing
            WB.Close()
            W = Nothing
        ' Quit Excel
            XL.Quit()
            XL = Nothing
        Dts.TaskResult = ScriptResults.Success
         End Sub

    Hi,
    If you do not define GLOBAL VARIABLE in your BPC package and BIDS, why don't you try to have it? you should specify the webfolder and file name in advanced script, then you also need to create global variable as text type in BIDS.
    I saw many cases BPC does not pass the dynamic variable to BIDS, therefore I changed the type of variable as the Global variable and it works for me.
    Regards,
    YH Seo

  • 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.

  • Excel Sheet Looping: For each loop from variable Enumerator

    Hi,
    Is it possible to do excel sheets looping using For each loop Enumerator as "For Each loop from Variable enumerator" ? If yes, please help.
    Also,
    I have an excel file with 10 sheets, but want to loop only 5 sheets. Please help..how can i achieve this. 
    Actually i tried with
    1> stored the 5 sheets name into a variable (say 'SheetsName') of type string using script task
    2> For each loop container
       enumerator - 'For each ADO Schema Rowset enumerator'
       connection: ADO
       schema: 'Tables'
       variable mapping: 'User::SheetsName'
    3> Within For each loop container added a data flow task
    4> Inside DFT - excel source - 
       Data access Mode: 'Table Name or view name variable'
       Variable Name: 'SheetsName'
    but this loops through all the 10 sheets irrespective of only 5 sheets names stored in the variable "SheetsName".
    Please help...
    Please Mark as Answer if my post solved your problem or Vote As Helpful if this helps. Blogs: www.sqlserver2005forum.blogspot.com

    >> Is it possible to do excel sheets looping using For each loop Enumerator as "For Each loop from Variable enumerator" ? If yes, please help.
    I don't think so. To loop through all worksheets of Excel For ADO.NET Schema Rowset Enumerator is the only option.
    Please refer:
    https://msdn.microsoft.com/en-us/library/ms345182(v=sql.110).aspx
    >> I have an excel file with 10 sheets, but want to loop only 5 sheets
    So you have configured For Each loop container which loops throgh all sheets and returns you sheet name to variable "SheetName".
    Drag and drop one Sequence Container inside ForEach Loop Container and connect it to Data Flow Task.
    Right click on connector and use expression: (which will check if current sheet is one of 5 required sheets)
    @User::SheetName == "FirstSheet" ||  @User::SheetName == "SecondSheet" || .....
    Below blog demonstrates kind of simillar steps:
    http://www.bidn.com/blogs/MikeDavis/ssis/559/ssis-skip-certain-files-in-a-for-each-loop 
    -Vaibhav Chaudhari

  • 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  

  • 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

  • SSIS Script task not executing macro through SQL Agent (but it does through bids)

    <p>Hello everyone,</p><p>I am having an issue with SQL Agent when executing a macro contained in a script task component. The script task actually opens an excel file, runs the macro, save and closes the file. </p><p>When
    I execute the package via BIDS/Visual studio, it works like a charm. However, when i execute the package with SQL agent, the package runs successfully but it seems that the macro is not executed as the excel file has not been modified as it should have. Also,
    the history log does not show any error messages. </p><p>Could </p>

    Thanks!I did create a credential and a proxy too but still the macro is not executed.I have searched online for solutions but no one has experimented this kind of issue before it seems. Please have a look at the script task code:
    Imports
    Excel = Microsoft.Office.Interop.Excel
    Imports
    System
    Imports
    System.Data
    Imports
    System.Math
    Imports
    Microsoft.SqlServer.Dts.Runtime
    <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 Macro_name
    As
    String
    Dim ExcelObject
    As
    New Microsoft.Office.Interop.Excel.Application
    Dim oBook
    As Microsoft.Office.Interop.Excel.Workbook
    Dim oBooks
    As Microsoft.Office.Interop.Excel.Workbooks
    Try
    Macro_name =
    "Macro001"
    ExcelObject =
    CType(CreateObject("Excel.Application"),
    Excel.Application)
    ExcelObject.Visible =
    True
    ExcelObject.UserControl =
    False
    ExcelObject.DisplayAlerts =
    False
    oBooks = ExcelObject.Workbooks
    oBook =
    CType(oBooks.Open("C\Book1.xls"),
    Excel.WorkbookClass)
    ExcelObject.Run(Macro_name)
    Catch ex
    As Exception
    ExcelObject.Application.Quit()
    ExcelObject.DisplayAlerts =
    True
    ExcelObject =
    Nothing
    End
    Try
    Dts.TaskResult = ScriptResults.Success
    End
    Sub
    End
    Class

  • Format of Excel Sheet

    Hi experts,
    I am working on Account receivables in oracle applications.I am getting one problem . I run my query in Toad and I am saving output in .xls format.i got output in comma separted.like
    cust_no|Cust_name|trx_no|trx_date|amount|open_bal|closed_bal|curr_bal
    1 xxx 110 12/01/06 10000 50000 60000 10000
    But i want output like this
    Cust_no:1
    Cust_name:xxx
    open_bal:50000
    Trx_no Trx_date Amount Curr_bal
    110 12/01/06 10000 10000
    closed_bal:60000.
    I want output like this in excel sheet.
    how to do This?Please give me solution.
    I want this output by using query only to display in excel sheet.Dont use rdf and anything.
    My code is:
    SELECT
    HCA.ACCOUNT_NUMBER ACCOUNT_NUMBER
    ,RCT.TRX_NUMBER TRX_NUMBER
    ,HP.PARTY_NAME PARTY_NAME
    ,DECODE(RCT.STATUS_TRX,'OP','OPEN','CLOSED') STATUS
    ,HL.ADDRESS1 || HL.ADDRESS2 || HL.ADDRESS3|| HL.PROVINCE || HL.CITY || HL.STATE ||HL.POSTAL_CODE || HL.COUNTRY ADDRESS
    ,HCSU.LOCATION LOCATION
    ,RCT.TRX_DATE TRX_DATE
    ,APS.DUE_DATE DUE_DATE
    ,RCTG.GL_DATE GL_DATE
    ,APS.AMOUNT_DUE_ORIGINAL AMOUNT_DUE_ORIGINAL
    ,APS.AMOUNT_DUE_REMAINING AMOUNT_DUE_REMAINING
    ,APS.AMOUNT_APPLIED AMOUNT_APPLIED
    ,DECODE(RCTT.TYPE,'DM','DEBIT MEMO','CM','CREDIT MEMO','DEP','DEPOSIT','GUAR','GURANTEE','INVOICE') TYPE
    ,RCTT.STATUS STATUS1
    ,RBS.NAME NAME
    ,RCT.CT_REFERENCE CT_REFERENCE
    ,F1(HCA.ACCOUNT_NUMBER,'01-OCT-2007') OPENING_BALANCE
    ,F2(HCA.ACCOUNT_NUMBER,RCT.TRX_NUMBER,'01-OCT-2007','04-NOV-2007') CURRENT_BAL
    ,F1(HCA.ACCOUNT_NUMBER,'01-OCT-2007') + F2(HCA.ACCOUNT_NUMBER,RCT.TRX_NUMBER,'01-OCT-2007','04-NOV-2007') CLOSED_BAL
    ,GCC.SEGMENT1 BC
    FROM
    RA_CUSTOMER_TRX_ALL RCT
    ,AR_PAYMENT_SCHEDULES_ALL APS
    ,RA_CUST_TRX_TYPES_ALL RCTT
    ,RA_CUST_TRX_LINE_GL_DIST_ALL RCTG
    ,RA_BATCH_SOURCES_ALL RBS
    ,HZ_PARTY_SITES HPS
    ,HZ_PARTIES HP
    ,HZ_CUST_ACCOUNTS HCA
    ,HZ_CUST_SITE_USES_ALL HCSU
    ,HZ_CUST_ACCT_SITES_ALL HCAS
    ,HZ_LOCATIONS HL
    ,GL_CODE_COMBINATIONS GCC
    WHERE
    RCT.CUSTOMER_TRX_ID=APS.CUSTOMER_TRX_ID
    AND RCTT.CUST_TRX_TYPE_ID=RCT.CUST_TRX_TYPE_ID
    AND RCTG.CUSTOMER_TRX_ID=RCT.CUSTOMER_TRX_ID
    AND RCT.BATCH_SOURCE_ID=RBS.BATCH_SOURCE_ID
    AND HP.PARTY_ID = HCA.PARTY_ID
    AND HP.PARTY_ID=HPS.PARTY_ID
    AND HL.LOCATION_ID = HPS.LOCATION_ID
    AND HCA.CUST_ACCOUNT_ID =HCAS.CUST_ACCOUNT_ID
    AND HCAS.CUST_ACCT_SITE_ID = HCSU.CUST_ACCT_SITE_ID
    AND HPS.PARTY_SITE_ID = HCAS.PARTY_SITE_ID
    AND RCT.BILL_TO_SITE_USE_ID = HCSU.SITE_USE_ID
    AND GCC.CODE_COMBINATION_ID = RCTG.CODE_COMBINATION_ID
    AND HCSU.SITE_USE_CODE = 'BILL_TO'
    AND RCTG.GL_DATE BETWEEN '01-OCT-2007' AND '04-NOV-2007'
    AND RCT.TRX_NUMBER = '1107010103'
    GROUP BY
    HCA.ACCOUNT_NUMBER
    ,RCT.TRX_NUMBER
    ,HP.PARTY_NAME
    ,DECODE(RCT.STATUS_TRX,'OP','OPEN','CLOSED')
    ,HL.ADDRESS1 || HL.ADDRESS2 || HL.ADDRESS3|| HL.PROVINCE || HL.CITY || HL.STATE ||HL.POSTAL_CODE || HL.COUNTRY
    ,HCSU.LOCATION
    ,RCT.TRX_DATE
    ,APS.DUE_DATE
    ,RCTG.GL_DATE
    ,APS.AMOUNT_DUE_ORIGINAL
    ,APS.AMOUNT_DUE_REMAINING
    ,APS.AMOUNT_APPLIED
    ,DECODE(RCTT.TYPE,'DM','DEBIT MEMO','CM','CREDIT MEMO','DEP','DEPOSIT','GUAR','GURANTEE','INVOICE')
    ,RCTT.STATUS
    ,RBS.NAME
    ,RCT.CT_REFERENCE
    ,GCC.SEGMENT1

    I'm not looking at your code as you haven't formatted it on the forum. To do this use [code][/code] or [pre][/pre] tags around the code. Try editing your first post and re-pasting the code using those tags so we can read it.
    You are currently getting...
    SQL> with t as (select 1 as cust_no
      2                   ,'xxx' as cust_name
      3                   ,110 as trx_no
      4                   ,to_date('12/01/2006','DD/MM/YYYY') as trx_date
      5                   ,10000 as amount
      6                   ,50000 as open_bal
      7                   ,60000 as close_bal
      8                   ,10000 as curr_bal
      9             from dual)
    10  -- END OF TEST DATA
    11  select * from t;
       CUST_NO CUS     TRX_NO TRX_DATE                AMOUNT   OPEN_BAL  CLOSE_BAL   CURR_BAL
             1 xxx        110 12/01/2006 00:00:00      10000      50000      60000      10000And you want something like this?
    SQL> with t as (select 1 as cust_no
      2                   ,'xxx' as cust_name
      3                   ,110 as trx_no
      4                   ,to_date('12/01/2006','DD/MM/YYYY') as trx_date
      5                   ,10000 as amount
      6                   ,50000 as open_bal
      7                   ,60000 as close_bal
      8                   ,10000 as curr_bal
      9             from dual)
    10  -- END OF TEST DATA
    11  select col1||','||col2||','||col3||','||col4
    12  from (
    13        select cust_no, 1 as ord_col, 'Cust_no:' as col1, TO_CHAR(cust_no) as col2, null as col3, null as col4 from t union all
    14        select cust_no, 2, 'Cust_name:', cust_name, null, null from t union all
    15        select cust_no, 3, 'Open_bal:', TO_CHAR(open_bal), null, null from t union all
    16        select cust_no, 4, 'Trx_no', 'Trx_date', 'Amount', 'Curr_bal' from t union all
    17        select cust_no, 5, TO_CHAR(trx_no), TO_CHAR(trx_date, 'DD/MM/YY'), TO_CHAR(amount), TO_CHAR(curr_bal) from t union all
    18        select cust_no, 6, 'Close_bal:', TO_CHAR(close_bal), null, null from t
    19        )
    20  order by cust_no, ord_col;
    COL1||','||COL2||','||COL3||','||CO
    Cust_no:,1,,
    Cust_name:,xxx,,
    Open_bal:,50000,,
    Trx_no,Trx_date,Amount,Curr_bal
    110,12/01/06,10000,10000
    Close_bal:,60000,,
    6 rows selected.
    SQL>Remember, Comma seperated files are NOT excel files. .xls files are proprietary microsoft format files. If you save your data out as comma seperated you should use the file extension ".csv".
    Excel can recognise CSV files and will load them in, as can other products.

  • Non-English string access from excel sheet through JDBC

    My excel sheet data is
    Test ������������
    I am using JDBC connectivity for accessing the Excel sheet.
    Code looks like,
    List Output = new List();
    try
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    c = DriverManager.getConnection( "jdbc:odbc:qa-list", "", "" );
    stmnt = c.createStatement();
    ResultSet rs = stmnt.executeQuery("select * from [Sheet1$];");
    ResultSetMetaData rsmd = rs.getMetaData();
    int numberOfColumns = rsmd.getColumnCount();
    for(int i=1; i <= numberOfColumns; i++){
    Output.add(rsmd.getColumnLabel(i));
    catch( Exception e )
    System.err.println( e );
    finally
    try
    stmnt.close();
    c.close();
    catch( Exception e )
    System.err.println( e );
    Now. I am showing those data into the table(JTable) Applet programming.
    For, English string it is showing properly but, for non-English string are showing �???????????????????�
    I would like to know what could be the reason.
    Addional info:
    ava version "1.6.0_01"
    Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
    Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)
    If possible please send some reference code .

    I have one excel sheet which having differenct countries specific meaining of common words.
    I am using JDBC connectivity for accessing that Excel sheet.
    Code looks like,
    List Output = new List();
    try
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    c = DriverManager.getConnection( "jdbc:odbc:qa-list", "", "" );
    stmnt = c.createStatement();
    ResultSet rs = stmnt.executeQuery("select * from [Sheet1$];");
    ResultSetMetaData rsmd = rs.getMetaData();
    int numberOfColumns = rsmd.getColumnCount();
    for(int i=1; i <= numberOfColumns; i++){
    Output.add(rsmd.getColumnLabel(i));
    catch( Exception e ){
    System.err.println( e );
    finally{
    try{
    stmnt.close();
    c.close();
    catch( Exception e ){
    System.err.println( e );
    Now. I am showing those output data into the table(JTable) in my Applet programming.
    For, English string it is showing properly but, for non-English strings are showing question marks like, �?????�
    I would like to know what could be the reason.
    Please help me, i am stuck in my project.

Maybe you are looking for

  • How can I export a keynote proyect to a movie?

    I am making an assigment for the university and I don't know how to export a keynote presentation to a movie, ( with short videos and narration inside of it ). I tried quicktime export and it didin't work , the whole timing thing was awful! I really

  • Mapping Versions/History in Integration Repository

    We are running PI7.0 - SP10....  A highly suspect version with some ropey patches supplied by SAP! We have imported a Mapping version into our XIT system that does not work, however, our XID system is about to be either restored or upgraded due to so

  • No thumbnails for XPM images

    I used to see thumbnails for my xpm images in Finder, however now I no longer see any thumbnails or preview images. How does one fix this?

  • Problem integrating own javascripts in a Custom build component

    Hi all, I have created an own component and included in the IC WebClient (CRM 2007). The component contains a view with a custom layout implemented directly in the related *.htm page in the respective BSP Application. This works great if I just add s

  • Can Solaris 11 support Solaris 8/9 container?

    Dear all, I am new to Solaris 11. I know that Solaris 10 SPARC can support Solaris 8/9 container. So, Can Solaris 11 SPARC support Solaris 8/9 container? Wait for your feedback. Mike