Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to pass global Variable to DTS from ASP .NET

Status
Not open for further replies.

skitty123

Technical User
May 4, 2004
56
US
I want to run a DTS package from an ASP.NEt application
and pass a Date variable to the package without which it cannot run
can anyone tell me how to achive this?

thx

 
I know you've asked for ASP.NET, but in VB 6 you'll do it like this ...

objPackage.GlobalVariables("FromDate").Value = dtpFrom.Value
objPackage.GlobalVariables("ToDate").Value = dtpTo.Value

Hope this will put you on the right track.
[flowerface]



I was standing in the park, wondering why frisbees got bigger as they came closer... then it hit me!
 
thank you both for your replys
Tb: can you please tell me what data type the dtpFrom and dtpTo are?

Thanks
 
JVS thanks so much for the link!
JB: Can you also tell if you have to remove the Global variable and then add it again with its new value or if you just used a statement like
objPackage.GlobalVariables("FromDate").Value = <mynewdate>
before executing it?
Thanks.
 
>can you please tell me what data type the dtpFrom and dtpTo are?

These are date controls within my app and in the DTS they are Data Type-> Date

[flowerface]



I was standing in the park, wondering why frisbees got bigger as they came closer... then it hit me!
 
thanks tb.
I am still having trouble running the my DTS package: it just doesnt seem to execute ! and no errors are thrown either,
(I also posted it as a new question today: thread961-860379) trying to find out where I am going wrong?
thanks.
here is my code:
//-----------------------------begin----------
Package2Class package = new Package2Class();
object pVarPersistStgOfHost = null;
package.LoadFromSQLServer("(local)",null,null,DTSSQLServerStorageFlags.DTSSQLStgFlag_UseTrustedConnection,null,null,null,packageName,ref pVarPersistStgOfHost);

package.GlobalVariables.Remove("gv_startDate");
package.GlobalVariables.AddGlobalVariable("gv_startDate", gvValue);
package.Execute();
package.UnInitialize();

// force Release() on COM object
System.Runtime.InteropServices.Marshal.ReleaseComObject(package);
package = null;
//-----------------------------end
 
The only difference that I can see to my code is that I do not remove and add the Global variable ... I just pass the new value through.

As I said before >I know you've asked for ASP.NET, but in VB 6 you'll do it like this ...

So here is my code for executing ...

Dim objPackage As DTS.Package2

'Instanciate the DTS package object
Set objPackage = New DTS.Package2

'Set the server/username/password and the DTS package to be run
objPackage.LoadFromSQLServer Server, UserName, Password, DTSSQLStgFlag_Default, "", "", "", "DTS_PackageName"

objPackage.GlobalVariables("FromDate").Value = dtpFrom.Value
objPackage.GlobalVariables("ToDate").Value = dtpTo.Value

'Set object to raise an error on failure and to do eventlogs
objPackage.FailOnError = True
objPackage.WriteCompletionStatusToNTEventLog = True

'Run DTS Package
objPackage.Execute

objPackage.UnInitialize

Set objPackage = Nothing

Hope this helps ...
[flowerface]

I was standing in the park, wondering why frisbees got bigger as they came closer... then it hit me!
 
thanks tb.my code seems to be fine too, I think the problem is that I am trying to transfer contents from a text file that is on a remote drive ( which I mapped to teh sql server machine) so when I try to run it from code, it cannot connect to the drive... I dont knwo which user name and password it uses.. is there a work around for this or a way to force it to conenct to teh remote file location?
 
I have never done this ... anybody else got any ideas?

I was standing in the park, wondering why frisbees got bigger as they came closer... then it hit me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top