Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Error in script task with VB script in SSIS.

$
0
0

Hi,

I am getting below error in script task with VB script when I am running my SSIS package through SQL agent Job.

Also I am using same script with my other package to get file_name and it working good till this package.

Message
Executed as user: ALICOCORP\NTSQL_DEV. Microsoft (R) SQL Server Execute Package Utility  Version 10.50.2500.0 for 32-bit  Copyright (C) Microsoft Corporation 2010. All rights reserved.    Started:  9:14:15 AM  Error: 2012-12-17 09:14:18.84     Code: 0x00000001     Source: Get File Name      Description: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Argument 'Length' must be greater or equal to zero.     at Microsoft.VisualBasic.Strings.Mid(String str, Int32 Start, Int32 Length)     at ST_da4e787e25fa410ea686eb08c141b41e.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()  End Error  DTExec: The package execution returned DTSER_FAILURE (1).  Started:  9:14:15 AM  Finished: 9:14:18 AM  Elapsed:  2.902 seconds.  The package execution failed.  The step failed.

Below is script which I am using in script task to get file name:

Public Sub Main()
 
         
        Dim sFinalFileNameAndPath As String
        Dim str1 As Integer = 0
        Dim str2 As String = ""
 
        sFinalFileNameAndPath = Dts.Variables("File_Path").Value.ToString
 
        str1 = InStrRev(sFinalFileNameAndPath, "\")



        Dts.Variables("File_Name").Value = Mid(sFinalFileNameAndPath, str1 + 1, InStrRev(sFinalFileNameAndPath, ".") - (str1 + 1))



Dts.TaskResult = ScriptResults.Success
End Sub

End Class


Please let me know how to solve this. Thanks for the help in advance.


Vicky



Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>