Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server DTS
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #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 0 Times in 0 Posts
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 0 Times in 0 Posts
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 0 Times in 0 Posts
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

 


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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
DTS Visual Basic ActiveX Script jemacc SQL Server DTS 4 November 28th, 2007 05: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 04:11 PM
Accessing DTS scripting object in ActiveX script. panakiom SQL Server DTS 0 August 22nd, 2005 08:41 AM



All times are GMT -4. The time now is 12:25 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.