执行包时,脚本任务出现此错误。我试图通过插入断点来调试脚本,但30分钟后没有出现错误。它在运行脚本时显示警告。它会在某个时候解压缩一些文件,但大多数时候我只是看到警告并指示我进入脚本调试模式。
警告:ST处的0x0(设置变量):无法连接VSTA调试器。重新启动调试可能会解决问题。
这是一个vb脚本。它试图找到数据文件,然后解压缩数据文件。
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Imports System.IO
Imports System.Text
<Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute> _
<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 strCommandLine As String
Dim strCommandLineArg As String
Dim strFirstLine As String
Dim count As Integer
Dim countChar As Integer
Dim objStreamReader As StreamReader
objStreamReader = New StreamReader(Dts.Variables("LoopFile").Value.ToString)
strFirstLine = objStreamReader.ReadLine()
objStreamReader.Close()
Dim objFileInfo As FileInfo = New FileInfo(Dts.Variables("LoopFile").Value.ToString)
count = strFirstLine.Split("|").Length - 1
countChar = strFirstLine.Split(":").Length - 1
If objFileInfo.Length < 1000 And countChar = 0 Then
Dts.Variables("FileType").Value = "EMPTY"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_ALLERGY_") Then
Dts.Variables("FileType").Value = "ECW_ALLERGY"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE TEMP_ECW_ALLERGY"
Dts.Variables("strSQL_Merge").Value = "EXEC usp_ETL_Update_ECW_ALLERGY"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_APPT_") Then
Dts.Variables("FileType").Value = "ECW_APPT"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE TEMP_ECW_APPT"
Dts.Variables("strSQL_Merge").Value = "EXEC usp_ETL_Update_ECW_APPT"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_BILL_") And count = 136 Then
Dts.Variables("FileType").Value = "ECW_BILL"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE TEMP_ECW_BILL"
Dts.Variables("strSQL_Merge").Value = "EXEC usp_ETL_Update_ECW_BILL"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_BILL_") And count = 127 Then
Dts.Variables("FileType").Value = "ECW_BILL_Old"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE TEMP_ECW_BILL_Old"
Dts.Variables("strSQL_Merge").Value = "EXEC usp_ETL_Update_ECW_BILL_Old"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_ENC_") Then
Dts.Variables("FileType").Value = "ECW_ENC"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE TEMP_ECW_ENC"
Dts.Variables("strSQL_Merge").Value = "EXEC usp_ETL_Update_ECW_ENC"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_ENC-HPI_") Then
Dts.Variables("FileType").Value = "ECW_ENC-HPI"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE [TEMP_ECW_ENC-HPI]"
Dts.Variables("strSQL_Merge").Value = "EXEC [usp_ETL_Update_ECW_ENC-HPI]"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_IMMUN_") Then
Dts.Variables("FileType").Value = "ECW_IMMUN"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE TEMP_ECW_IMMUN"
Dts.Variables("strSQL_Merge").Value = "EXEC usp_ETL_Update_ECW_IMMUN"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_LBRSLT_") Then
Dts.Variables("FileType").Value = "ECW_LBRSLT"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE TEMP_ECW_LBRSLT"
Dts.Variables("strSQL_Merge").Value = "EXEC usp_ETL_Update_ECW_LBRSLT"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_LBRSLT-FALL_") Then
Dts.Variables("FileType").Value = "ECW_LBRSLT-FALL"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE [TEMP_ECW_LBRSLT-FALL]"
Dts.Variables("strSQL_Merge").Value = "EXEC [usp_ETL_Update_ECW_LBRSLT-FALL]"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_LBRSLT-HPI_") Then
Dts.Variables("FileType").Value = "ECW_LBRSLT-HPI"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE [TEMP_ECW_LBRSLT-HPI]"
Dts.Variables("strSQL_Merge").Value = "EXEC [usp_ETL_Update_ECW_LBRSLT-HPI]"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_LBRSLT-PHQ2_") Then
Dts.Variables("FileType").Value = "ECW_LBRSLT-PHQ2"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE [TEMP_ECW_LBRSLT-PHQ2]"
Dts.Variables("strSQL_Merge").Value = "EXEC [usp_ETL_Update_ECW_LBRSLT-PHQ2]"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_LBRSLT-PHQ9_") Then
Dts.Variables("FileType").Value = "ECW_LBRSLT-PHQ9"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE [TEMP_ECW_LBRSLT-PHQ9]"
Dts.Variables("strSQL_Merge").Value = "EXEC [usp_ETL_Update_ECW_LBRSLT-PHQ9]"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_LBRSLT-PREV_") Then
Dts.Variables("FileType").Value = "ECW_LBRSLT-PREV"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE [TEMP_ECW_LBRSLT-PREV]"
Dts.Variables("strSQL_Merge").Value = "EXEC [usp_ETL_Update_ECW_LBRSLT-PREV]"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_MED_") Then
Dts.Variables("FileType").Value = "ECW_MED"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE TEMP_ECW_MED"
Dts.Variables("strSQL_Merge").Value = "EXEC usp_ETL_Update_ECW_MED"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_PRB_") And count = 60 Then
Dts.Variables("FileType").Value = "ECW_PRB"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE TEMP_ECW_PRB"
Dts.Variables("strSQL_Merge").Value = "EXEC usp_ETL_Update_ECW_PRB"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_PRB_") And count = 56 Then
Dts.Variables("FileType").Value = "ECW_PRB_Old"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE [TEMP_ECW_PRB_Old]"
Dts.Variables("strSQL_Merge").Value = "EXEC [usp_ETL_Update_ECW_PRB_Old]"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_PRB-PREV_") Then
Dts.Variables("FileType").Value = "ECW_PRB-PREV"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE [TEMP_ECW_PRB-PREV]"
Dts.Variables("strSQL_Merge").Value = "EXEC [usp_ETL_Update_ECW_PRB-PREV]"
'ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_PSTAT_") Then
' Dts.Variables("FileType").Value = "ECW_PSTAT"
' Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE TEMP_ECW_PSTAT"
' Dts.Variables("strSQL_Merge").Value = "EXEC usp_ETL_Update_ECW_PSTAT"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_RECON_") Then
Dts.Variables("FileType").Value = "ECW_RECON"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE TEMP_ECW_RECON"
Dts.Variables("strSQL_Merge").Value = "EXEC usp_ETL_Update_ECW_RECON"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_SOCHX_") Then
Dts.Variables("FileType").Value = "ECW_SOCHX"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE TEMP_ECW_SOCHX"
Dts.Variables("strSQL_Merge").Value = "EXEC usp_ETL_Update_ECW_SOCHX"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_VITAL_") Then
Dts.Variables("FileType").Value = "ECW_VITAL"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE TEMP_ECW_VITAL"
Dts.Variables("strSQL_Merge").Value = "EXEC usp_ETL_Update_ECW_VITAL"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_SVC_") Then
Dts.Variables("FileType").Value = "ECW_SVC"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE TEMP_ECW_SVC"
Dts.Variables("strSQL_Merge").Value = "EXEC usp_ETL_Update_ECW_SVC"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_SVC-CAREPLAN_") Then
Dts.Variables("FileType").Value = "ECW_SVC-CAREPLAN"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE [TEMP_ECW_SVC-CAREPLAN]"
Dts.Variables("strSQL_Merge").Value = "EXEC [usp_ETL_Update_ECW_SVC-CAREPLAN]"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_SVC-DF_") Then
Dts.Variables("FileType").Value = "ECW_SVC-DF"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE [TEMP_ECW_SVC-DF]"
Dts.Variables("strSQL_Merge").Value = "EXEC [usp_ETL_Update_ECW_SVC-DF]"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_SVC-HPI_") Then
Dts.Variables("FileType").Value = "ECW_SVC-HPI"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE [TEMP_ECW_SVC-HPI]"
Dts.Variables("strSQL_Merge").Value = "EXEC [usp_ETL_Update_ECW_SVC-HPI]"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_SVC-PREV_") Then
Dts.Variables("FileType").Value = "ECW_SVC-PREV"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE [TEMP_ECW_SVC-PREV]"
Dts.Variables("strSQL_Merge").Value = "EXEC [usp_ETL_Update_ECW_SVC-PREV]"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_SVC-REF_") Then
Dts.Variables("FileType").Value = "ECW_SVC-REF"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE [TEMP_ECW_SVC-REF]"
Dts.Variables("strSQL_Merge").Value = "EXEC [usp_ETL_Update_ECW_SVC-REF]"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_SVC-SPECTEST_") Then
Dts.Variables("FileType").Value = "ECW_SVC-SPECTEST"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE [TEMP_ECW_SVC-SPECTEST]"
Dts.Variables("strSQL_Merge").Value = "EXEC [usp_ETL_Update_ECW_SVC-SPECTEST]"
ElseIf Dts.Variables("LoopFile").Value.ToString.Contains("_ECW_SVC-SURGHX_") Then
Dts.Variables("FileType").Value = "ECW_SVC-SURGHX"
Dts.Variables("strSQL_TruncateTemp").Value = "TRUNCATE TABLE [TEMP_ECW_SVC-SURGHX]"
Dts.Variables("strSQL_Merge").Value = "EXEC [usp_ETL_Update_ECW_SVC-SURGHX]"
Else
Dts.Variables("FileType").Value = ""
Dts.Variables("strSQL_TruncateTemp").Value = ""
Dts.Variables("strSQL_Merge").Value = ""
End If
If Len(Dts.Variables("FileType").Value) > 0 Then
If Right(Dts.Variables("LoopFile").Value.ToString.ToUpper, 4) = ".TXT" Then
Dts.Variables("File").Value = Dts.Variables("LoopFile").Value
ElseIf Right(Dts.Variables("LoopFile").Value.ToString.ToUpper, 3) = ".GZ" Then
strCommandLine = """C:\Program Files\7-Zip>7z """
strCommandLineArg = " e -y "
strCommandLineArg = strCommandLineArg & Dts.Variables("LoopFile").Value.ToString
strCommandLineArg = strCommandLineArg & " -o"
strCommandLineArg = strCommandLineArg & Dts.Variables("PhytelUploadECW").Value.ToString
Dts.Variables("File").Value = Left(Dts.Variables("LoopFile").Value, Len(Dts.Variables("LoopFile").Value) - 3)
Dts.Variables("strCmdLine").Value = strCommandLine
Dts.Variables("strCmdLineArg").Value = strCommandLineArg
Else
Dts.Variables("FileType").Value = ""
Dts.Variables("File").Value = ""
Dts.Variables("strCmdLine").Value = ""
Dts.Variables("strCmdLineArg").Value = ""
End If
Else
Dts.Variables("strUnmappedFiles").Value = Dts.Variables("strUnmappedFiles").Value + Dts.Variables("LoopFile").Value + vbCrLf
Dts.Variables("File").Value = ""
Dts.Variables("strCmdLine").Value = ""
Dts.Variables("strCmdLineArg").Value = ""
End If
Dts.Variables("intImportResult").Value = 0
objFileInfo = Nothing
Dts.TaskResult = ScriptResults.Success
End Sub
End Class
有人有任何想法吗?