在SQLServer2000 中建了一个DTS包, 用于从paradox表导入到SQLServer中。我把这个DTS包 保存为结构化存储文件,名为:DataTrans.dts, 在delphi中用dtsrun命令执行这个包
Winexec('dtsrun /DataTrans.dts /DataTrans /Mpackage_password',1)
执行不成功, why?

解决方案 »

  1.   

    另外一个简单调用的例子:
    In Delphi 7:use Variants;iPkg:Variant;iPkg:=CreateOleObject('DTS.Package'); //CreateOleObject('DTS.Package2') is ok too. (check Sql Help) 
    iPkg.LoadFromSQLServer(ServerName,UserName,Password,0,'','','',PackageName);
    iPkg.Execute;
    iPkg.Uninitialize;
    iPkg:=Null;
      

  2.   

    Another way:
    object.LoadFromStorageFile(
    UNCFile,
    Password,
    [PackageID],
    [VersionID],
    [Name],
    [pVarPersistStgOfHost])Part Description 
    Package Expression that evaluates to an object in the Applies To list 
    UNCFile File name 
    Password Package password if the package is encrypted 
    PackageID ITDS package identifier 
    RevisionID Version identifier 
    Name Package name 
    pVarPersistStgOfHost Screen layout information associated with a package (for internal use) 
    Res
    If RevisionID is not specified or is blank, the most recent version of the package is retrieved.