question

manuu avatar image
manuu asked

Convert vb script into C# script in ssis

Hi Friends, I have a script in vb.net which gives sum of 2 variables. I need to convert it in C# for ssis script task. Below is the script: **************************************** Public Sub Main() 'MessageBox.Show("TotalCount" & Dts.Variables("TotalCount").Value.ToString()) Dts.Variables("TotalCount").Value = Convert.ToInt32(Dts.Variables("TotalCount").Value) + Convert.ToInt32(Dts.Variables("Insert_Count").Value) Dts.Variables("ErrorNewRowCount").Value = Convert.ToInt32(Dts.Variables("ErrorNewRowCount").Value) + Convert.ToInt32(Dts.Variables("Error_Count").Value) 'MessageBox.Show("TotalCountContainer" & Dts.Variables("TotalCountContainer").Value.ToString()) 'MessageBox.Show("TotalCount" & Dts.Variables("TotalCount").Value.ToString()) 'Dts.Variables("Insert_Count").Value = 0 'MessageBox.Show("TotalCount : " & Dts.Variables("TotalCount").Value.ToString()) 'MessageBox.Show("ErrorNewRowCount : " & Dts.Variables("ErrorNewRowCount").Value.ToString()) Dts.TaskResult = ScriptResults.Success End Sub *************************************************** Please help me out......Thanks in advance...
ssis
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
iainrobertson avatar image
iainrobertson answered
From the first result of a google search for convert vb.net to c#: http://converter.telerik.com/ public void Main() { MessageBox.Show("TotalCount" + Dts.Variables("TotalCount").Value.ToString()); Dts.Variables("TotalCount").Value = Convert.ToInt32(Dts.Variables("TotalCount").Value) + Convert.ToInt32(Dts.Variables("Insert_Count").Value); Dts.Variables("ErrorNewRowCount").Value = Convert.ToInt32(Dts.Variables("ErrorNewRowCount").Value) + Convert.ToInt32(Dts.Variables("Error_Count").Value); MessageBox.Show("TotalCountContainer" + Dts.Variables("TotalCountContainer").Value.ToString()); MessageBox.Show("TotalCount" + Dts.Variables("TotalCount").Value.ToString()); Dts.Variables("Insert_Count").Value = 0; MessageBox.Show("TotalCount : " + Dts.Variables("TotalCount").Value.ToString()); MessageBox.Show("ErrorNewRowCount : " + Dts.Variables("ErrorNewRowCount").Value.ToString()); Dts.TaskResult = ScriptResults.Success; } Note that I uncommented your commented lines to ensure correct conversion. To re-comment them, use the // comment marker
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.