Dealy

Dealy

  • NA
  • 209
  • 0

Error when running DTS package from code

Jan 18 2010 2:12 PM
Hello,

i need to run a DTS Package that exports tables to an Access file, so I'm using the following code:
  // Name of the package to run
string packageName = "Backup";
object pVarPersistStgOfHost = null;

DTS.PackageClass package = new DTS.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.

Answers (1)