i need to run a DTS Package that exports tables to an Access file, so I'm using the following code:
Java
// Name of the package to runstringpackageName="Backup";
objectpVarPersistStgOfHost=null;
DTS.PackageClasspackage=newDTS.PackageClass();
package.LoadFromSQLServer("localhost", "sa", "sa", DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_UseTrustedConnection
, null, null, null, packageName, ref pVarPersistStgOfHost);
try
{
// Execute the package
Console.WriteLine("DTS Package Executing..");
package.Execute();
Console.WriteLine("DTS Package Completed");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
package.UnInitialize();
package = null;
}
The problem is that i get the following error message: The type or namespace name 'DTS' could not be found (are you missing a using directive or an assembly reference?) D:\Visual Studio 2008\......
Any ideas what do i do wrong?
Thank you in advance.
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
I found the solution... for those who have the same problem you just have to add reference to the Microsoft DTSPackage Object Library version 2.0 COM object.
Dealy132 pointsPosted Jan 18, 2010, 9:28 AM EST
http://support.microsoft.com/default.aspx/kb/319985