Code of the SSIS script component

Source: Internet
Author: User
Tags ssis

Http://topic.csdn.net/u/20090708/11/7344c5ad-fcc0-4e19-a21a-0e3c2ea25407.html

Http://www.windbi.com/showtopic.aspx? Topicid = 1345 & page = end
Http://topic.csdn.net/u/20090617/15/a9a58f90-77fc-4e0d-b780-8bdc5cc6dc8b.html
Http://support.microsoft.com/kb/918760

Http://blogs.msdn.com/ B /jorgepc/archive/2008/02/12/ssis-error-dts-e-cannotacquireconnectionfromconnectionmanager-when-connecting-to-oracle-data-source.aspx

Public class scriptmain:
Usercomponent

{
Idtsconnectionmanager100 connmgr;
Sqlconnection sqlconn;
Sqlcommand sqlcmd;
Sqlparameter sqlparam;

Public override void acquireconnections (Object Transaction)
{

Connmgr = This. Connections. myadonetconnectionmanager;
Sqlconn = (sqlconnection) connmgr. acquireconnection (null );

}

Public override void preexecute ()
{

Sqlcmd = new sqlcommand ("insert into person. address2 (addressid, city)" +
"Values (@ addressid, @ city)", sqlconn );
Sqlparam = new sqlparameter ("@ addressid", sqldbtype. INT );
Sqlcmd. Parameters. Add (sqlparam );
Sqlparam = new sqlparameter ("@ City", sqldbtype. nvarchar, 30 );
Sqlcmd. Parameters. Add (sqlparam );

}

Public override void myaddressinput_processinputrow (myaddressinputbuffer row)
{
{
Sqlcmd. Parameters ["@ addressid"]. value = row. addressid;
Sqlcmd. Parameters ["@ City"]. value = row. City;
Sqlcmd. executenonquery ();
}
}

Public override void releaseconnections ()
{

Connmgr. releaseconnection (sqlconn );

}

}

C # VB Replication
Using system. IO;
Public class scriptmain:
Usercomponent

{
String copiedaddressfile;
Private streamwriter textwriter;
Private string columndelimiter = ",";

Public override void acquireconnections (Object Transaction)
{

Idtsconnectionmanager100 connmgr = This. Connections. myflatfiledestconnectionmanager;
Copiedaddressfile = (string) connmgr. acquireconnection (null );

}

Public override void preexecute ()
{

Textwriter = new streamwriter (copiedaddressfile, false );

}

Public override void myaddressinput_processinputrow (myaddressinputbuffer row)
{

{
If (! Row. addressid_isnull)
{
Textwriter. Write (row. addressid );
}
Textwriter. Write (columndelimiter );
If (! Row. city_isnull)
{
Textwriter. Write (row. City );
}
Textwriter. writeline ();
}

}

Public override void postexecute ()
{

Textwriter. Close ();

}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.