Hi,
this is what I use, I create a DTS from enterprise manager , where the data
is comnig from and where to put it, then select "create a file" or something
similar in the DTS wizard, it does create a .dts file this is the one you
will use later
Here is the code, note that I change the datasource from the code, you can
do a similar thing with the destination:
Also you need to add a reference to DTS COM library
using DTS;
using System.Data;
using System.Data.SqlClient;
void RunPackage( string packSource, string packName, string dataSource)
{
try
{
Package2Class package = new Package2Class();
object pVarPersistStgOfHost = null;
// if you need to load from file
package.LoadFromStorageFile(
packSource,
null,
null,
null,
packName,
ref pVarPersistStgOfHost);
/*
package.LoadFromSQLServer(
"",
null,
null,
DTSSQLServerStorageFlags.DTSSQLStgFlag_UseTrustedConnection,
null,
null,
null,
"Test Import Package",
ref pVarPersistStgOfHost);
*/
package._Package_Connections.Item(1).DataSource = dataSource;
package.Execute();
package.UnInitialize();
// force Release() on COM object
//
System.Runtime.InteropServices.Marshal.ReleaseComObject(package);
package = null;
}
catch(System.Runtime.InteropServices.COMException e)
{
Console.WriteLine("COMException {0}", e.ErrorCode.ToString() );
Console.WriteLine("{0}", e.Message);
Console.WriteLine("{0}", e.Source);
Console.WriteLine("Stack dump\n{0}\n", e.StackTrace);
Console.ReadLine();
}
catch(System.Exception e)
{
Console.WriteLine("Exception");
Console.WriteLine("{0}", e.Message);
Console.WriteLine("{0}", e.Source);
Console.WriteLine("Stack dump\n{0}\n", e.StackTrace);
Console.ReadLine();
}
}

Signature
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
> Thanks Ignacio, what sort of code is it that you have? I would be
> interested in taking a look.
[quoted text clipped - 6 lines]
> Sent via .NET Newsgroups
> http://www.dotnetnewsgroups.com