Board index » delphi » Using DTS from Delphi

Using DTS from Delphi

Show your original code that works (using variants) and your new code that
does not work (using TPackage).

have fun
--
Binh Ly
http://www.techvanguards.com

Quote
"Ian Darroch" <i.darr...@geac.com> wrote in message news:39dcf7eb_2@dnews...
> I have written a utility which can open a DTS package by using a variant
and
> calling CreateOleObject('DTS.Package'). I can then manipulate the object
to
> get its properties, and even call the Execute method. However, using this
> method I am not able to access the events generated by the package as it
> executes.

> I have also tried importing the type library, and creating an instance of
a
> TPackage object, setting its properties and calling the Execute method.
> However, when I do this, I get an access violation error.

> Can someone help me with how to use the DTS package from Delphi?

> Thanks,
> Ian

 

Re:Using DTS from Delphi


Ian,
Check out .attachements I just posted some sample code from a conference
session I did.

The code builds a DTS package and then allows you to execute any DTS package
and includes the event code. The event code was generated by Binh Ly's
utility.

You will need to import the DTS Type Libraries for the DTS Package and the
DTS Pump, my code was written against the 8.0 type libs but does not use any
of the new interfaces so should work against 7.0 as well.

-Euan

Quote
"Ian Darroch" <i.darr...@geac.com> wrote in message news:39dd1bd9_1@dnews...
> Here is the sample code:

> This one works:

> var pkgObj: Variant;
> begin
>   pkgObj := CreateOleObject('DTS.Package');
>   pkgObj.LoadFromSQLServer( txtServer.Text, txtUser.Text,
txtPassword.Text,
>                             DTSSQLStgFlag_Default, txtPackagePass.Text,
'',
> '',
>                             txtPackage.Text);
>   pkgObj.Execute;

> This one causes Access Violation error:

> var pkgObj : TPackage;
> begin
>   pkgObj := TPackage.Create(TComponent(Sender));
>   pkgObj.LoadFromSQLServer(txtServer.Text, txtUser.Text, txtPassword.Text,
>                            DTSSQLStgFlag_Default, txtPackagePass.Text, '',
> '',
>                            txtPackage.Text );
>   pkgObj.Execute;

> TIA,
> Ian.

> Binh Ly wrote in message <39dd0955_1@dnews>...
> >Show your original code that works (using variants) and your new code
that
> >does not work (using TPackage).

> >have fun
> >--
> >Binh Ly
> >http://www.techvanguards.com

Re:Using DTS from Delphi


Just checked the .attachements newsgrooup and my message to you is there
with a zip file attachement.

-Euan

Quote
"Ian Darroch" <i.darr...@geac.com> wrote in message news:39dd33bd_2@dnews...
> Euan,

> I don't see any attachments on the message. Where should I be looking?
(new
> to newsgroups I am!).

> Thanks,
> Ian.

> Euan Garden wrote in message <8rjb43$8...@bornews.borland.com>...
> >Ian,
> >Check out .attachements I just posted some sample code from a conference
> >session I did.

> >The code builds a DTS package and then allows you to execute any DTS
> package
> >and includes the event code. The event code was generated by Binh Ly's
> >utility.

> >You will need to import the DTS Type Libraries for the DTS Package and
the
> >DTS Pump, my code was written against the 8.0 type libs but does not use
> any
> >of the new interfaces so should work against 7.0 as well.

> >-Euan

Re:Using DTS from Delphi


I have written a utility which can open a DTS package by using a variant and
calling CreateOleObject('DTS.Package'). I can then manipulate the object to
get its properties, and even call the Execute method. However, using this
method I am not able to access the events generated by the package as it
executes.
I have also tried importing the type library, and creating an instance of a
TPackage object, setting its properties and calling the Execute method.
However, when I do this, I get an access violation error.

Can someone help me with how to use the DTS package from Delphi?

Thanks,
Ian

Re:Using DTS from Delphi


Here is the sample code:

This one works:

var pkgObj: Variant;
begin
  pkgObj := CreateOleObject('DTS.Package');
  pkgObj.LoadFromSQLServer( txtServer.Text, txtUser.Text, txtPassword.Text,
                            DTSSQLStgFlag_Default, txtPackagePass.Text, '',
'',
                            txtPackage.Text);
  pkgObj.Execute;

This one causes Access Violation error:

var pkgObj : TPackage;
begin
  pkgObj := TPackage.Create(TComponent(Sender));
  pkgObj.LoadFromSQLServer(txtServer.Text, txtUser.Text, txtPassword.Text,
                           DTSSQLStgFlag_Default, txtPackagePass.Text, '',
'',
                           txtPackage.Text );
  pkgObj.Execute;

TIA,
Ian.

Quote
Binh Ly wrote in message <39dd0955_1@dnews>...
>Show your original code that works (using variants) and your new code that
>does not work (using TPackage).

>have fun
>--
>Binh Ly
>http://www.techvanguards.com

Re:Using DTS from Delphi


Euan,

I don't see any attachments on the message. Where should I be looking? (new
to newsgroups I am!).

Thanks,
Ian.

Quote
Euan Garden wrote in message <8rjb43$8...@bornews.borland.com>...
>Ian,
>Check out .attachements I just posted some sample code from a conference
>session I did.

>The code builds a DTS package and then allows you to execute any DTS
package
>and includes the event code. The event code was generated by Binh Ly's
>utility.

>You will need to import the DTS Type Libraries for the DTS Package and the
>DTS Pump, my code was written against the 8.0 type libs but does not use
any
>of the new interfaces so should work against 7.0 as well.

>-Euan

Re:Using DTS from Delphi


Euan,

I found and have tried the sample ExecutePackage, only modifying it to
specify a different server than (local). Unfortunately, when I try to run
it, it gets up to the line where it calls the execute method on the package
(FPackage.Execute), and locks up really badly (I usually have to re-start my
machine to recover). The package I am trying to run works normally from
Enterprise Manager on this machine.

I aslo tried removing the HookEvents and Unhook events calls, and this DID
allow the package to execute (but of course did not tell me what happened
during execution).

Any thoughts?

Ian.

Re:Using DTS from Delphi


Euan,

Further to my previous message, I have found that if I set
ExecuteOnMainThread to true for all steps, without removing the
HookEvents/UnhookEvents calls, the package does run and call the events.
What do I need to do to enable multi-threading in the example program?

Thanks,

Ian.

Other Threads