Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server DTS
|
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
 
Old May 13th, 2005, 08:19 AM
Registered User
 
Join Date: May 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default DTSGlobalVar lose its value in VBScript

Hi, all,
i have a strange problem with the following VBscript-Code:

Code:
Function Main()
    ...

    ''''''''''DTSGlobalVariables("myGlobVar").Value = "xyz"

    If DTSGlobalVariables("myGlobVar").Value = "xyz" Then

        sTmpVar = DTSGlobalVariables("myGlobVar").Value
        retVal = doSomething( sTmpVar )
        MsgBox retVal

    End If


Function doSomething( sTmpVar ) 
    ...
    doSomething = retVal
End Function
The Problem is with the following call from a SQL-Stored Procedure:

dtsrun /S myserver /U sa /P sa /N MyPacket /M sa /A myGlobVar:8="xyz"

At runtime, the If-Condition gets true, but then sTmpVar is NULL
and I get the report of a runtime error in doSomething().
The DTSGlobalVariable is set correctly in the Package Properties
and when I set the DTSGlobalVariable inside the Main-Function of this
script, it works.

Thanks for every tip
willi

 
Old May 20th, 2005, 03:50 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Other than re-arrange the code to:
Code:
Function Main()
    ...

    ''''''''''DTSGlobalVariables("myGlobVar").Value = "xyz"
    Dim sTmpVar
    sTmpVar = DTSGlobalVariables("myGlobVar").Value 
    If sTmpVar = "xyz" Then    
         retVal = doSomething( sTmpVar )
        MsgBox retVal

    End If
I can't see why your code fails.

Are you sure that you haven't mistyped an identifier? Do you have Option Explicit set?


--

Joe (Microsoft MVP - XML)
 
Old August 29th, 2005, 03:26 PM
Registered User
 
Join Date: Jul 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have the same problem. In an active X script, I assign today's
date to gv_ImportDate, after having created the global variable. Then I display it in a message box to test it. Msgbox displays the
correct date.

However, I cannot use the variable in the where clause of a SQL
query. I am trying to return data from JET. It succeeds if I
hard code my where clause to "where info_dt = #8/28/2005#"

Any help out there please?






Similar Threads
Thread Thread Starter Forum Replies Last Post
User controls lose data edibusl ASP.NET 2.0 Basics 0 October 7th, 2006 09:10 AM
Avoid Warning Message on C lose Windows qazi_nomi Javascript 9 September 11th, 2004 11:19 AM
Help! At a lose: SQL and VB xgbnow Pro VB Databases 2 June 9th, 2004 10:12 PM
Why do I lose 0 Zero's when calculating? easybee Classic ASP Databases 1 December 18th, 2003 12:34 AM





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