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

编程入门 行业动态 更新时间:2024-10-28 12:20:41
本文介绍了SSIS 脚本组件:Microsoft.SqlServer.Dts.Pipeline.BlobColumn的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与 C# 组件斗争.我想要做的是在我的输入源中取一列 ntext 用管道分隔,然后将数组写入文本文件.当我运行我的组件时,我的输出如下所示:

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

我一直在使用 GetBlobData 方法,但我正在努力解决它.非常感谢任何帮助!这是完整的脚本:

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:UsersUserDesktopLocal_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/201001257/converting-microsoftsqlserverdtspipelineblobcolumn-to-string-in-ssis-using-c

这篇关于SSIS 脚本组件:Microsoft.SqlServer.Dts.Pipeline.BlobColumn的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-03-29 13:23:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/756092.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:脚本   组件   Microsoft   SSIS   Pipeline

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!