Link to home
Start Free TrialLog in
Avatar of ravi_net
ravi_net

asked on

executing DTS package from ASP.NET with VB.NET

Hi,
I need to run a simple DTS package from the asp.net page.  i have button on the webform i need to run the dts package for that button click event.
I was trying to find examples on the internet, but i could not find a simple answer..

Using one of the articles i have created ref to dts dll file and was working with it. My dts execution process is taking to too long, in fact i never had it finished. when i run the package in enterprise manager it takes less than a min.

here is the sample code that i used.

Dim package As DTS.Package2Class
        package = New DTS.Package2Class
        Dim infos As DTS.SavedPackageInfos
        package.LoadFromSQLServer("(LOCAL)", "sa", "passwd", DTS.DTSSQLServerStorageFlags.DTSSQLStgFlag_Default, "", "", "", "ProcessDB", "")
        package.Execute()
        package.UnInitialize()
        package = Nothing

I would be thankfull if some one could point me to a simple example or a sample code.
Thank you in advance
Ravi
Avatar of bwdowhan
bwdowhan

Here is the link to the Microsoft Knowledge base on this:

http://support.microsoft.com/default.aspx?scid=KB;EN-US;q252987&ID=KB;EN-US;q252987

It actually describes the process very well and includes sample code..

~Brian
SOLUTION
Avatar of arbert
arbert

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The DTSRUNUI utility isn't a bad way to go. In fact to make it easier to make changes, you could save the DTSRUN as a batch file by generating the execution string in the utility, saving it in a batch file and using xp_cmdshell to run your batch program.

I have an implementation of a WROX press com+ object that allows web driven requests to manage the execution of DTS packages. Of course you would have to write your own security around the COM object which gets more involved but it works very well, especially when you need users to execute jobs at non-specific times. At WROX Press, it is the Professional SQL Server 2000 DTS book.

~Brian
Why make it so complicated????
Avatar of ravi_net

ASKER

Hi
Thanks for your comments.
I was able to run a simple pacage using the above code.
But when i run this particular package it takes very long time (i don't know how long. coz it is still running). Why is taking so long when i could run the package in less than one min from enterprise manager??

Is there any thing wrong with the code i used above??

bwdowhan, i have been throw that article and it explains about asp. i used some part of that article and trying to work it with asp.net

albert, i think the params that should pass to the dtsrun are the same as the ones that i mentioned in my previous posting!!! dbname, username, password..etc....
So, i don't think that should make much of a difference.

Thank you in advance for any further pointers.
Ravi
arbert, if you are referring to the COM+ object, my asp page dynamically pulls in global variables and allows users to control the values to create custom processes, that's a different story though...

As for the processing taking so long, I would look at potential locks or resource issues. Does this DTS process pull data or push data to a different server or share drive or is everything done on the server?

~Brian
Brian,
I am doing evertying on the same machine. i have couple of table with around 600 record overall. my package process the entire cube.

I changed the cube such that it only process one dimention but still it taking long time.

I ran the dtsrun.exe from command line with the parameters and it got executed.

Could you give me more details how i could run this with in vb.net.

albert, as you said i was tring to run the execute method on conn object. i assume that you are reffering to the sqlconn object and there is no method as execute on connection class!!!

Thank you in advance
ravi
I would look at permission problems--are you sure that it's actually running when you call it from xp_cmdshell?  Are you executing both tests with the same account?

Did you run sp_who from query analyzer to see if it's actually running or if there is any locking/blocking?
Albert,
I am running both from the same account.
Here the commands and output i got...

dtsrun /S(local) /NProcessDb /Usa /Ppassword

when i run this from command promt i got this result

DTSRun:  Loading...
DTSRun:  Executing...
DTSRun OnStart:  DTSStep_DTSOlapProcess.Task_1
DTSRun OnFinish:  DTSStep_DTSOlapProcess.Task_1
DTSRun:  Package execution complete.

i believe that the package is getting executed.
When i run the same command with different package (creates a folder), its working fine.

i think i need a way to work the above command from vb.net

Thanks in advane
Ravi
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
If you are calling the package from ASP.NET, the package is executing most likely under the ASPNET user's security context so you will need to make sure that the ASPNET user has access to all the resources used in your package (databases, files, DLLs,...whatever). Even though you have specified "sa" in LoadFromSQLServer, that is NOT the security context when you call Execute.
"the package is executing most likely under the ASPNET"

Depending on the security model that you defined for your .NEt application...
I had working using the storedprocedure. Storedprocedure runs the dtsrun utility on xp_cmdshell and provides the required params.
Thanks for the info guys...