Skip to content

Error when running DTS package from code

Dealy

Asked Jan 18, 2010, 9:12 AM EST1 answer
Share
LinkedInX
Hello,

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 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.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.