Microsoft KB Archive/247356

= How To Execute a SQL Server 7.0 DTS Package from Visual FoxPro =

Article ID: 247356

Article Last Modified on 7/1/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q247356



SUMMARY
SQL Server 7.0 Data Transformation Services (DTS) allows the definition of processes which import, export, or transform data and can be saved as packages. Each DTS package defines a workflow that includes one or more tasks executed in a coordinated sequence as steps. After a DTS package has been created and saved, it is completely self-contained and can be retrieved and executed using the following:

The DTS run command prompt utility.SQL Server Agent to run a scheduled job that executes the package.The DTS Designer user interface.The DTS Export and Import Wizard user interfaces.The Execute method of a DTS Package object in a custom application. This article describes how to use the Execute method of a DTS Package object in a custom Visual FoxPro application.



MORE INFORMATION
When accessing DTS Packages stored in the Microsoft Repository, the LoadFromRepository method is used. This method accepts the following parameters:

When accessing DTS Packages stored in a file, the LoadFromStorageFile method is used. This method accepts the following parameters:

 From SQL Server 7.0 Enterprise Manager, create a DTS package and save it to the Repository as DTSPkgAlpha. From SQL Server 7.0 Enterprise Manager, create a second DTS package and save it to a file as DTSPkgBeta.DTS  Create a program file named Reposit.prg, using the following code: *!* Create a DTS Package Object dtsPkg=CREATEOBJECT('dts.package')


 * !* Change My_Server to reflect the server name.
 * !* Change My_UserID and My_Password to reflect your User ID and Password
 * !* Obtain the Package ID and Version ID from the Properties Sheet
 * !* of the DTS Package

dtsPkgName=dtsPkg.LoadFromRepository("My_Server","MSDB","My_UserID",;  "My_Password","Package ID","Version ID","DTSPkgAlpha") dtsPkg.Execute RELEASE dtsPkg  Run Reposit.prg, and note the results of the DTS Package.  Create a program file named Dtsfile.prg using the following code: *!* Create a DTS Package Object dtsPkg=CREATEOBJECT('dts.package')
 * !* Load the package to be executed from the Repository
 * !* Execute the DTS Package
 * !* Release the DTS Package


 * !* LoadFromStorageFile requires the following parameters:
 * !* UNC path to the .DTS file to be executed
 * !* User Password

dtsPkgName=dtsPkg.LoadFromStorageFile("\\UNC_Path_to\DTSPkgBeta.dts","User_Password") dtsPkg.Execute RELEASE dtsPkg  Run Dtsfile.prg, and note the results of the DTS Package.</ol>
 * !* Load the package to be executed from a file.
 * !* Execute the DTS Package
 * !* Release the DTS Package

<div class="references_section">