SSISスクリプトタスクでVBスクリプトを使用して、ヘッダーとトレーラーをフラットファイルに追加しています。最近、私は、ファイル内の行が通常よりもされている問題に出くわしたとerror`Errorとスクリプトタスクの障害になるまで、コードが正常に動作したSystem.out of memory SSISスクリプトの文字列ビルダーの例外タスク
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.String.GetStringForStringBuilder(String value, Int32 startIndex, Int32 length, Int32 capacity) at System.Text.StringBuilder.GetNewString(String currentString, Int32 requiredLength) at System.Text.StringBuilder.Append(Char[] value, Int32 startIndex, Int32 charCount) at System.IO.StreamReader.ReadToEnd() at System.IO.File.ReadAllText(String path, Encoding encoding) at System.IO.File.ReadAllText(String path)`
いずれかが固定で私を助けることができます私は他の文字列関連のメソッドを使用する必要があります "文字列ビルダー"の代わりに思う。私はここで fileContents.Append(。File.ReadAllText(Dts.Connections( "DestinationConnection")のConnectionString))での誤差
を取得しています私のコードです:
Public Sub Main()
Dim fileContents As New StringBuilder()
Dim finalfile As String
Dim firstline As String
Dim lastline As String
Dts.VariableDispenser.LockForRead("FirstLine")
Dts.VariableDispenser.LockForRead("LastLine")
Dts.VariableDispenser.LockForRead("FileName")
firstline = CType(Dts.Variables("FirstLine").Value, String)
finalfile = CType(Dts.Variables("FileName").Value, String)
lastline= CType(Dts.Variables("LastLine").Value, String)
'Write header, then append file contents and write back out.
fileContents.AppendLine(String.Format("{0}", firstline))
fileContents.Append(File.ReadAllText(Dts.Connections("DestinationConnection").ConnectionString))
fileContents.AppendLine(String.Format("{0}", lastline))
File.WriteAllText(finalfile, fileContents.ToString())
Dts.TaskResult = ScriptResults.Success
End Sub
あなたは、コードiamで理解しようとしていますが、私は同じエラーtahnksを取得しています。 – lch
私はちょうど私が見つけたスクリプトを編集しています。それが役立つかどうかを見てください。 – Josh