dbTalk Databases Forums  

Using VB.net to execute DTS

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Using VB.net to execute DTS in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
sltech
 
Posts: n/a

Default Using VB.net to execute DTS - 02-02-2004 , 07:47 PM






Hi,

I found a lot of resources on the internet to execute a DTS package from
VB.net. I tested my code on a test DTS package to make sure it worked and
it did. The vb code does work for a DTS package that does not prompt for a
value.

Now, the real DTS package I have to run, does not work, it seems to hang.
This DTS package (when you run it from enterprise manager) prompts for a
value in an input box when you run it. I think this is causing the
problem.... I did not write the DTS package and don't know how to do so...

So...

I want to pass a variable to the DTS package through VB.net. The DTS
package is prompting for a user input when you run it from enterprise
manager. Do I need to change the DTS code or the code in VB?


Here's my VB code for reference:
Dim DTSParameter As String
Dim dtsImport As New DTS.Package2
Dim stp As DTS.Step

DTSParameter = DropDownList1.SelectedItem.Value

With dtsImport
..LoadFromSQLServer("SQLSERVER", "sa", "thepassword", , , , , "DTS Package")
..GlobalVariables.AddGlobalVariable("PROMPTEDVALUE ", DTSParameter)
..FailOnError = True
..Execute()
End With

Thanks,
-C

Reply With Quote
  #2  
Old   
Russel Loski, MCSD
 
Posts: n/a

Default RE: Using VB.net to execute DTS - 02-02-2004 , 08:06 PM






You will have to edit the DTS package

Somewhere in the package there is an InputBox command. You could comment out the InputBox command. It should look like

myVar = InputBox("My Prompt"

Put in its place

myVar = DTSGlobalVariable("PROMPTEDVALUE"

The inputbox code is most likely in an ActiveX script task. You would be crazy to use it in a transformation script

Russ

Reply With Quote
  #3  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Using VB.net to execute DTS - 02-03-2004 , 01:16 AM



You are right the prompt is killing the package. The prompt is opening but
you can't see it to reply to it. In the code there will be a INPUTBOX
statement
The task in which it is more then likley will be in ActiveScript task. This
looks like a VB Global Module icon.

You need a way of doing the same thing but differently.

Look at putting a Dynamic properties task in the package.



--

----------------------------

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.allisonmitchell.com - Expert SQL Server Consultancy.
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


"sltech" <ads4sms (AT) yahoo (DOT) com> wrote

Quote:
Hi,

I found a lot of resources on the internet to execute a DTS package from
VB.net. I tested my code on a test DTS package to make sure it worked and
it did. The vb code does work for a DTS package that does not prompt for
a
value.

Now, the real DTS package I have to run, does not work, it seems to hang.
This DTS package (when you run it from enterprise manager) prompts for a
value in an input box when you run it. I think this is causing the
problem.... I did not write the DTS package and don't know how to do
so...

So...

I want to pass a variable to the DTS package through VB.net. The DTS
package is prompting for a user input when you run it from enterprise
manager. Do I need to change the DTS code or the code in VB?


Here's my VB code for reference:
Dim DTSParameter As String
Dim dtsImport As New DTS.Package2
Dim stp As DTS.Step

DTSParameter = DropDownList1.SelectedItem.Value

With dtsImport
.LoadFromSQLServer("SQLSERVER", "sa", "thepassword", , , , , "DTS
Package")
.GlobalVariables.AddGlobalVariable("PROMPTEDVALUE" , DTSParameter)
.FailOnError = True
.Execute()
End With

Thanks,
-C



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.