SSIS脚本组件:Microsoft.SqlServer.Dts.Pipeline.BlobColumn [英] SSIS Script Component: Microsoft.SqlServer.Dts.Pipeline.BlobColumn
本文介绍了SSIS脚本组件:Microsoft.SqlServer.Dts.Pipeline.BlobColumn的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
用C#组件中的挣扎。我所试图做的是采取即在其中与分隔管我的输入源NTEXT一列,然后写入阵列到一个文本文件中。当我运行我的分量我的输出是这样的:
DealerID,StockNumber,期权
161552,P1427,微软。 SqlServer.Dts.Pipeline.BlobColumn
香港专业教育学院一直与GetBlobData方法和IM与它挣扎。任何帮助,不胜感激!以下是完整的脚本:
公共覆盖无效Input0_ProcessInputRow(Input0Buffer行)
{
串vehicleoptionsdelimited = Row.Options.ToString();
//字符串OptionBlob = Row.Options.GetBlobData(INT;
//字符串vehicleoptionsdelimited = System.Text.Encoding.GetEncoding(Row.Options.ColumnInfo.CodePage).GetChars(OptionBlob);
的String []选项= vehicleoptionsdelimited.Split('|');
路径字符串= @C:\Users\User\Desktop\Local_DS_CSVs\;
的String [] headerline =
{
DealerID+,+StockNumber+,+选项
};
系统。 IO.File.WriteAllLines(路径+OptionInput.txt,headerline);
使用(System.IO.StreamWriter文件=新System.IO.StreamWriter(路径+OptionInput.txt,真))
{
的foreach(字符串s选件)
{
file.WriteLine(Row.DealerID.ToString()+,+ Row.StockNumber.ToString() +,+ S);
}
}
解决方案
尝试使用
BlobToString(Row.Options)
使用此功能:
私人字符串BlobToString( BlobColumn BLOB)
{
字符串结果=;
试
{
如果(BLOB!= NULL)
{
结果= System.Text.Encoding.Unicode.GetString(blob.GetBlobData(0,转换。 ToInt32(blob.Length)));
}
}
赶上(异常前)
{
结果= ex.Message;
}
返回结果;
}
Struggling with a C# Component. What I am trying to do is take a column that is ntext in my input source which is delimited with pipes, and then write the array to a text file. When I run my component my output looks like this:
DealerID,StockNumber,Option
161552,P1427,Microsoft.SqlServer.Dts.Pipeline.BlobColumn
Ive been working with the GetBlobData method and im struggling with it. Any help with be greatly appreciated! Here is the full script:
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
string vehicleoptionsdelimited = Row.Options.ToString();
//string OptionBlob = Row.Options.GetBlobData(int ;
//string vehicleoptionsdelimited = System.Text.Encoding.GetEncoding(Row.Options.ColumnInfo.CodePage).GetChars(OptionBlob);
string[] option = vehicleoptionsdelimited.Split('|');
string path = @"C:\Users\User\Desktop\Local_DS_CSVs\";
string[] headerline =
{
"DealerID" + "," + "StockNumber" + "," + "Option"
};
System.IO.File.WriteAllLines(path + "OptionInput.txt", headerline);
using (System.IO.StreamWriter file = new System.IO.StreamWriter(path + "OptionInput.txt", true))
{
foreach (string s in option)
{
file.WriteLine(Row.DealerID.ToString() + "," + Row.StockNumber.ToString() + "," + s);
}
}
解决方案
Try using
BlobToString(Row.Options)
using this function:
private string BlobToString(BlobColumn blob)
{
string result = "";
try
{
if (blob != null)
{
result = System.Text.Encoding.Unicode.GetString(blob.GetBlobData(0, Convert.ToInt32(blob.Length)));
}
}
catch (Exception ex)
{
result = ex.Message;
}
return result;
}
Adapted from: http://mscrmtech.com/201001257/converting-microsoftsqlserverdtspipelineblobcolumn-to-string-in-ssis-using-c
这篇关于SSIS脚本组件:Microsoft.SqlServer.Dts.Pipeline.BlobColumn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文