2014-06-16 34 views
-1

有誰知道我如何從嵌入XML的JSON獲取值並將其分配給SSIS中的變量?從XML中嵌入JSON獲取值的腳本

我有一個與像一個JSON值創建XML工作如下:

<string> 
{"result_code":1,"result_message":"All calling list successfully retrieved records number","total_records":0,"total_processed":0,"total_excluded":0,"ResultCSV":null,"number_callinglist_records":6015} 
</string> 

下面是我用從嵌入式JSON得到"number_calling_list"值,並將其分配給一個字符串變量的腳本:

Dim totalCount As String = "" 
If FileContents.Contains("number_callinglist_records") = True Then 
    totalCount = Dts.Variables("number_callinglist_records").Value 
End If 


If FileContents.Contains("number_callinglist_records") = True Then 
    EmailMessage = "List count has been successfully, see attached file for details " + totalCount 
Else : EmailMessage = "List count has been failed, please see attachment for details" 

它不工作,不過,當我運行它顯示了以下錯誤消息:

Microsoft.SqlServer.Dts.Runtime.DtsRuntimeException:在集合中找不到元素 。當您嘗試在包的執行 期間從容器集合中檢索元素並且該元素不存在時,會發生此錯誤。

有誰知道爲什麼會這樣,我怎麼能得到從嵌入式JSON的"number_callinglist_records"價值?

回答

0

您的Dts.Variables引用看起來不對。我會改變:

Dts.Variables("number_callinglist_records").Value 

Dts.Variables("User::number_callinglist_records").Value