1
Answer

Error when running DTS package from code

Dealy

Dealy

14y
4.7k
1
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)