2010-06-14 95 views
5

我有一個SSIS項目,我正在構建基於某些變量的SQL命令。我正在腳本任務中構建命令,並且想要將構造的SQL輸出到「執行結果」窗口。我想從我的腳本中做到這一點使用一個FireInformation行,如下所示:編輯ScriptMain.cs時在腳本任務中觸發事件

Dts.Events.FireInformation(99, "test", "Make this event appear!", "", 0, true); 

然而,在腳本編輯器,該線路將被強調爲紅色,鼠標懸停上,我得到的以下消息:

Error:
The best overloaded method match for 'Microsoft.SqlServer.Dts.Tasks.ScriptTask.EventsObjectWrapper.FireInformation(int, string, string, string, int, ref bool') has some invalid arguments

因此,我的腳本無法編譯,我無法執行它。

任何想法我在這裏做錯了什麼,或者我需要改變,以便能夠在執行輸出中的這一點上看到我的變量的值?

+0

Upvoted因爲這個問題,幫我實現Dts.events.FireInformation不會更新Windows事件日誌。 – 2017-05-02 10:54:07

回答

18

IDTSComponentEvents.FireInformation的最後一個參數是ref bool,而不是bool

所以,你需要一個參考傳遞給bool類型的變量,而不是一個bool值:

bool fireAgain = true; 
Dts.Events.FireInformation(..., ref fireAgain); 
8

您需要ref關鍵字:

bool b = true; 
Dts.Events.FireInformation(99, "test", "Make this event appear!", "", 0, ref b);