_대문 | 방명록 | 최근글 | 홈피소개 | 주인놈
FrontPage › SSIS-스크립트구성요소

Contents

[-]
1 누적(스크립트구성요소 - 변환)
2 원본
3 HexString To Binary


1 누적(스크립트구성요소 - 변환) #

  1. ' Microsoft SQL Server Integration Services user script component
  2. ' This is your new script component in Microsoft Visual Basic .NET
  3. ' ScriptMain is the entrypoint class for script components
  4.  
  5. Imports System
  6. Imports System.Data
  7. Imports System.Math
  8. Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
  9. Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
  10.  
  11. Public Class ScriptMain
  12.     Inherits UserComponent
  13.  
  14.     Dim CumulatedCnt As Integer
  15.  
  16.     Public Sub New()
  17.         CumulatedCnt = 0
  18.     End Sub
  19.  
  20.     Public Overrides Sub 입력0_ProcessInputRow(ByVal Row As 입력0Buffer)
  21.         '
  22.         ' Add your code here
  23.         '
  24.         CumulatedCnt = CumulatedCnt + Row.NewAccountCnt
  25.         Row.TotalAccountCnt = CumulatedCnt
  26.     End Sub
  27.  
  28. End Class
  29.  
* IE���� �ҽ� ����� �ٹٲ� �ȵ�. MS-Word � �ٿ� ��������. �ٹٲ� �Ǵ� ������: Chrome, Opera, Safari

2 원본 #

Imports System

Imports System.Data

Imports System.Math

Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper

Imports Microsoft.SqlServer.Dts.Runtime.Wrapper



Public Class ScriptMain

Inherits UserComponent







Public Overrides Sub CreateNewOutputRows()



With 출력0Buffer

.AddRow() : .COL1 = 1 : .COL2 = "'AAA'"

.AddRow() : .COL1 = 2 : .COL2 = "'BBB'"

.AddRow() : .COL1 = 3 : .COL2 = "'CCC'"

.AddRow() : .COL1 = 2 : .COL2 = "'ZZZ'"

.AddRow() : .COL1 = 2 : .COL2 = "'111'"

.AddRow() : .COL1 = 2 : .COL2 = "'ZZZ'"

End With



End Sub





End Class


3 HexString To Binary #

'Mac Address
Dim Mac(5) As Byte
Dim i As Integer


For i = 0 To Row.MacAddress.Length - 1 Step 2
    Mac(CType(i / 2, Int32)) = Convert.ToByte(Row.MacAddress.Substring(i, 2), 16)
Next
Row.MacAddrBin = Mac

/// <summary>  
/// Convert string to byte_array  
/// </summary>  
/// <param name="strInput">  
private byte[] String_To_Bytes(string strInput)  
{  
    // i variable used to hold position in string  
    int i = 0;  
    // x variable used to hold byte array element position  
    int x = 0;  
    // allocate byte array based on half of string length  
    byte[] bytes = new byte[(strInput.Length) / 2];  
    // loop through the string - 2 bytes at a time converting  
    //  it to decimal equivalent and store in byte array  
    while (strInput.Length > i + 1)  
    {  
        long lngDecimal = Convert.ToInt32(strInput.Substring(i, 2), 16);  
        bytes[x] = Convert.ToByte(lngDecimal);  
        i = i + 2;  
        ++x;  
    }  
    // return the finished byte array of decimal values  
    return bytes;  
}  
  
/// <summary>  
/// Convert byte_array to string  
/// </summary>  
/// <param name="bytes_Input">  
private string Bytes_To_String(byte[] bytes_Input)  
{  
    // convert the byte array back to a true string  
    string strTemp = "";  
    for (int x = 0; x <= bytes_Input.GetUpperBound(0); x++)  
    {  
        int number = int.Parse(bytes_Input[x].ToString());  
        strTemp += number.ToString("X").PadLeft(2, '0');  
    }  
    // return the finished string of hex values  
    return strTemp;  
}  

댓글 남기기..
이름: : 오른쪽의 새로고침을 클릭해 주세요. 새로고침
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:52

행복은 느낄 줄 아는 사람에게만 온다.