[英]Converting a (XML)String to DT_NTEXT inside a SSIS Script Component
Hey there, I have quite an Issue with an huge string from a Json.嘿,我有一个来自 Json 的巨大字符串的问题。 I want to write it into a Nvarchar(max) Column using the Script Component.我想使用脚本组件将它写入 Nvarchar(max) 列。
The OutputColumn is set to DT_NTEXT and I am using: OutputColumn 设置为 DT_NTEXT,我正在使用:
Output0Buffer.xdata.AddBlobData(System.Text.Unicode.UTF8.GetBytes(item.x_data));
The Jsonclass Item x_data is to string: Jsonclass Item x_data 是字符串:
... public string x_data { get; set; }...
The String is an XML that looks somthing like this:字符串是一个 XML,看起来像这样:
"<products>\r\n <product>\r\n <set>\r\n <pindex>PKHC544</pindex>\r\n <pvarindex><PKHC544><PKHC544.O08.MF1000></pvarindex> \r\n <child>\r\n <index>ZKVXXXXD</index>\r\n <varindex><ZKVXXXXD><ZKVXXXXDD00></varindex>\r\n </child> \r\n </set>\r\n </product>\r\n</products>"
My Error message is this:我的错误信息是这样的:
Error: 0xC0047062 at DF Load printcarrier_Orders, SC Import printcarrier_Orders [156]: System.ArgumentNullException: The string reference is not set to a string instance. Parameter name: s for Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.HandleUserException(Exception e) at Microsoft.SqlServer.Dts.Pipeline.ScriptComponentHost.PrimeOutput(Int32 outputs, Int32[] outputIDs, PipelineBuffer[] buffers) at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostPrimeOutput(IDTSManagedComponentWrapper100 wrapper, Int32 outputs, Int32[] outputIDs, IDTSBuffer100[] buffers, IntPtr ppBufferWirePacket)
I think I have a problem with the Encoding of this string, maybe x_data should have a different data type.我想我对这个字符串的编码有问题,也许 x_data 应该有不同的数据类型。 All other Columns are working smoothly.所有其他列都工作顺利。
Ok got the Issue solved, I was not checking for Null references before.好的,问题解决了,我之前没有检查 Null 参考。 It is not working if it is not included如果不包含它,它就不起作用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.