Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server DTS
| Search | Today's Posts | Mark Forums Read
SQL Server DTS Discussion specific to Data Transformation Service with SQL Server. General SQL Server discussions should use the general SQL Server forum. Readers of the book Professional SQL Server 2000 DTS with questions specific to that book should post in that book forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server DTS section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 17th, 2007, 02:06 PM
Registered User
 
Join Date: Apr 2007
Location: Crystal Lake, IL, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default DTS and ActiveX VB Script

Hi Everyone -
I am having a little problem and I think I can thank Microsoft for it. I am trying to create a DTS package that runs a select statement that is a count of rounds and based on the count I want to run one set of code or another set of code.
How would you go about this?
What I have tried is a SQL statement with a global variable and then I am trying to reference the global variable in an activex script task - and the task is failing -
Task code is:

' Visual Basic ActiveX Script
Function Main()
    dim sql
    set sql = DTSGlobalVariables("CountofRec").Value
    If sql > 700 Then <--I get a type mismatch on this line
    Main = DTSTaskExecResult_Success
    Else
    Main = DTSTaskExecResult_Failure
    End If
End Function

What is wrong with this? Please help! As I would so grateful for it:)
Lost
Gina
  #2 (permalink)  
Old April 18th, 2007, 05:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Try this...
Code:
'   Visual Basic ActiveX Script
Function Main()
    dim sql 
    sql = DTSGlobalVariables("CountofRec").Value
    MsgBox sql
    'If sql > 700  Then  <--I get a type mismatch on this line 
        'Main = DTSTaskExecResult_Success 
    'Else
        'Main = DTSTaskExecResult_Failure
    'End If
End Function
And see what it returns.

_________________________
- Vijay G
Strive for Perfection
  #3 (permalink)  
Old April 19th, 2007, 08:45 AM
Registered User
 
Join Date: Apr 2007
Location: Crystal Lake, IL, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I get object required.
Error Code: 0
VBscript runtime error
Object Required 'DTSGlobalVariables(...)Values.'
Error on Line 5

Wait! wait! - I rechecked my GLobal Variable declarations and fixed something there and now I get the error
Error Code: 0
VBScript runtime error
Type Mismatch
  #4 (permalink)  
Old April 19th, 2007, 09:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

So what is the fix you did with Global variable declaration?

Basically it looks like the following line doesn't return an integer value. It returns some object type, which you can't check against 700
Code:
sql = DTSGlobalVariables("CountofRec").Value
_________________________
- Vijay G
Strive for Perfection
  #5 (permalink)  
Old April 19th, 2007, 09:31 AM
Registered User
 
Join Date: Apr 2007
Location: Crystal Lake, IL, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I declared an output on a sql select statement that populates the countofrec variable. (Parameters and output parameters)
It is a select statement that counts the records and I want to compare that number and if it is higher then 700 do the rest of the dts package and if not just end.
  #6 (permalink)  
Old April 19th, 2007, 10:51 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

You can also refer this page - Using ActiveX Scripts in DTS

_________________________
- Vijay G
Strive for Perfection
  #7 (permalink)  
Old May 16th, 2007, 07:38 AM
Authorized User
Points: 209, Level: 4
Points: 209, Level: 4 Points: 209, Level: 4 Points: 209, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2005
Location: , , .
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default

On the pane on the left (two tabs, Language and Browser) you can double-click on the available global variables and it will paste the correct reference into your code.

Turn on just-in-time debugging and step through your code to make sure you're referencing the variable correctly. (Right-click "Data Transformation Services" in Enterprise Manager and there's an option to turn on Debugging.)

Then within your code place a STOP statement and it will break during execution. SAVE your package before debugging. The debugger will always (?) close Enterprise Manager after you're done debugging.

Nothing in your code off-hand looks odd. Your options to do what you want are to add an ActiveX script within the workflow properties, or to, as you're trying to do, use a pass/fail condition to branch.

SQLDTS.com has additional information that you may find helpful.

--Jeff



Similar Threads
Thread Thread Starter Forum Replies Last Post
DTS Visual Basic ActiveX Script jemacc SQL Server DTS 4 November 28th, 2007 06:11 PM
dts - formatting excel sheet using activex script Najmunnisha SQL Server DTS 2 May 17th, 2007 10:27 PM
DTS Problem with ActiveX Script testsubject SQL Server DTS 1 December 23rd, 2005 05:11 PM
Accessing DTS scripting object in ActiveX script. panakiom SQL Server DTS 0 August 22nd, 2005 08:41 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.