This article will focus on listing and executing DTS Packages and changing the attributes or global variables of DTS Packages.
First, let's take a look at how to list the local (local or (local) \ netsdk) servers that are saved as local packages. The key to processing DTS Packages in DOTNET is to add a reference to the "Microsoft dtspackage Object Library" (DTS. dll ).
If you want to use the latest version information, do not enter the version ID information. The Code is as follows:
Package. savetosqlserver ("(local) \ netsdk", "sa ","",
DTS. dtssqlserverstorageflags. dtssqlstgflag_default, "", "", ref Mia, false );
The following describes how to set the global variables of a data transmission package:
Static void main (string [] ARGs)
{
DTS. package2class package = new DTS. package2class ();
Try
{
Object Mia = system. reflection. Missing. value;
Package. loadfromstoragefile ("C: \ pubs2pubs2package. DTS ","","","",
"Pubs2pubs2package", ref Mia );
Package. globalvariables. addglobalvariable ("myvariable", "myvalue ");
Foreach (DTS. globalvariable gvar in package. globalvariables)
Console. writeline ("Name: {0} \ tvalue: {1}", gvar. Name, gvar. value );
}
Catch (exception ex)
{
Console. writeline (ex. Message );
}
Finally
{
Package. uninitialize ();
}
Console. Read ();
}
Modify the global variable value statement:
Package. globalvariables. Item ("myvariable"). let_value ("hello from C #");
The following statement saves the changes to the data transmission package.
Package. savetostoragefile ("C: \ pubs2pubs2package. DTS", "", ref Mia, false );
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.