Use C # To Call The SSIS package

Source: Internet
Author: User
Tags ssis

Test Platform: Windows2003 R2 SP2; SQL Server 2005 with all the latest patches; VS 2005 Professional Edition; vs2008.

Earlier versions:

[Technical Documentation] How to Use C # Call SSIS package

The following is an example:
To use a package with parameters, first introduce
Using Microsoft. sqlserver. DTS. runtime;
Then assign values to the package variables in the program. The specific method code is as follows:
Private void runetl ()
{
Console. writeline ("ETL start ...");
String filepath = installedpath + "// ETL // package. dtsx ";
Microsoft. sqlserver. DTS. runtime. Application application = new Microsoft. sqlserver. DTS. runtime. Application ();
Package package = application. loadpackage (filepath, null, true );
Package. Variables ["dbservername"]. value = dwservername;
Package. Variables ["dbname"]. value = dwdbname;
Package. Variables ["varfoldername"]. value = thispath;
Dtsexecresult result = package. Execute ();
If (result. Equals (dtsexecresult. Success ))
Listbox1.items. Add ("ETL success ");
Else
{
Listbox1.items. Add ("ETL failed ");
Return;
}
} The current environment should be:

Add references first

C:/program files/Microsoft SQL Server/90/SDK/assemblies/Microsoft. sqlserver. dtsruntimewrap. dll 9.0.242.0

 

After joining, Microsoft. sqlserver. dtsruntimewrap is displayed.

Using dtsruntime = Microsoft. sqlserver. DTS. runtime. wrapper;

This wrapper is available in new versions. For earlier versions, only using dtsruntime = Microsoft. sqlserver. DTS. Runtime is required.

Now we introduce using Microsoft. sqlserver. DTS. runtime. wrapper;String filepath = "t_ship_history_price.dtsx"; Microsoft. sqlserver. DTS. runtime. wrapper. application application = new Microsoft. sqlserver. DTS. runtime. wrapper. application (); <br/> Microsoft. sqlserver. DTS. runtime. wrapper. idtspackage90 package = application. loadpackage (filepath, true, null); <br/> // package. variables ["dbservername"]. value = dwservername; <br/> // package. variables ["dbname"]. value = dwdbname; <br/> // package. variables ["varfoldername"]. value = thispath; <br/> dtsexecresult result = package. execute (); <br/> // package. tolerations ["date"]. configurationstring = "20090214"; <br/> If (result. equals (dtsexecresult. dtser_success) <br/> textbox1.text = "ETL success"; <br/> else <br/>{< br/> textbox1.text = "ETL failed "; <br/> return; <br/>}

 

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.