Update Script component on fly
February 4th, 2015 11:33pm

Hi Vipin,

you have to use the Object variable type and pass that variable to script task.

please see the following article for your reference:

http://sqlage.blogspot.com.au/2013/07/ssis-how-to-read-object-type-variable.html

http://beyondrelational.com/modules/2/blogs/106/posts/11133/ssis-reading-object-variable-in-script-task.aspx

Thanks,

Zaim Raza

Free Windows Admin Tool Kit Click here and download it now
February 5th, 2015 12:50am

See if this helps

http://www.selectsifiso.net/?p=288

February 5th, 2015 12:52am

Hi,

If you want to chose all columns in your data, you shouldn't use dataflow task.

Step1: use SQL task to chose your data into variable:

In that task you should set "Result set" as "Full result set" and make a variable. In my case it call Params ("User::Params")


Step2: in script task you can use this variable:

System.Data.OleDb.OleDbDataAdapter adapter = new System.Data.OleDb.OleDbDataAdapter();
DataTable tmp = new DataTable();
adapter.Fill(tmp, Dts.Variables["User::Params"].Value);
if (tmp.Rows.Count == 1)
{
    foreach (DataRow row in tmp.Rows)
    {
        //put a row into string using \t delimiter
        tmpStr = string.Join("\t", row.ItemArray)+"\n";
    }
}
In my example, variable using to make a string text with delimiters.
  • Edited by xjomanx 4 hours 21 minutes ago
Free Windows Admin Tool Kit Click here and download it now
February 5th, 2015 2:06am

Thanks for you update sir ,

I want hash value of my all column

below is my original code which is static

************

Public Class ScriptMain
Inherits UserComponent

Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider()

Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)

Dim columnContents As Byte() = UnicodeEncoding.Unicode.GetBytes(Row.Col001 + Row.Col002 + Row.Col003 + Row.Col004 + Row.Col005 + Row.Col006 + Row.Col007 + Row.Col008)
System.Windows.Forms.MessageBox.Show(columnContents.ToString())

Dim hash As Byte() = md5.ComputeHash(columnContents)
Dim hashString As String = Convert.ToBase64String(hash, Base64FormattingOptions.None)

Row.RowChecksum = hashString
End Sub
End Class

********

I have to use script component instead of script task

how can I incopropare my code with your code ?

regards,

Vipin jha

February 5th, 2015 2:35am

You can use reflection to loop through all input columns in a Script Component.
Free Windows Admin Tool Kit Click here and download it now
February 5th, 2015 3:02am

You can use reflection to loop through all input columns in a Script
February 5th, 2015 3:06am

You can use reflection to loop through all input columns in a Script Compo

Free Windows Admin Tool Kit Click here and download it now
February 5th, 2015 3:26am

Why do you need to use script component instead of script task?

What the purpose?

In script component you cannot change columns on fly, because row class is generating, when you choosing input columns:


You can try to change input row class, but i think that it will be error in script.

Class can change here:


February 5th, 2015 6:07am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
Hi,
In my SSIS Project I am using Script component, below is the code.
I am referring 100 of table using single Data Flow Task, every table have different numbers of column.
I want to refresh the columns in input column tab with selected in script component transformation.
as you can see in code the column are static means table have 8 column.
what if the next table have 10 column .
I want to do it dynamically on fly.

Code:-

Public Class ScriptMain
Inherits UserComponent

Dim md5 As MD5CryptoServiceProvider = New MD5CryptoServiceProvider()

Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)

Dim columnContents As Byte() = UnicodeEncoding.Unicode.GetBytes(Row.Col001 + Row.Col002 + Row.Col003 + Row.Col004 + Row.Col005 + Row.Col006 + Row.Col007 + Row.Col008)
System.Windows.Forms.MessageBox.Show(columnContents.ToString())

Dim hash As Byte() = md5.ComputeHash(columnContents)
Dim hashString As String = Convert.ToBase64String(hash, Base64FormattingOptions.None)

Row.RowChecksum = hashString
End Sub
End Class

Please help me to achieve my requirement.

Regards,
Vipin jha