gpt4 book ai didi

c# - SSIS 脚本组件 : Microsoft. SqlServer.Dts.Pipeline.BlobColumn

转载 作者:太空狗 更新时间:2023-10-29 22:20:36 26 4
gpt4 key购买 nike

努力使用 C# 组件。我想要做的是在我的输入源中使用一个用管道分隔的 ntext 列,然后将该数组写入一个文本文件。当我运行我的组件时,我的输出如下所示:

DealerID,StockNumber,Option
161552,P1427,Microsoft.SqlServer.Dts.Pipeline.BlobColumn

我一直在使用 GetBlobData 方法,但遇到了困难。非常感谢任何帮助!这是完整的脚本:

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);
}
}

最佳答案

尝试使用

BlobToString(Row.Options)

使用这个函数:

  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;
}

改编自: http://mscrmtech.com/201001257/converting-microsoftsqlserverdtspipelineblobcolumn-to-string-in-ssis-using-c

关于c# - SSIS 脚本组件 : Microsoft. SqlServer.Dts.Pipeline.BlobColumn,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4822917/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com