activex script in DTS

Posted on 2005-04-20
Last Modified: 2013-11-30

How would I create a counter in an activex script.

For instance I would like to have a variable called counter and increment it.

Dim counter= 0

DTSDestination("fielda")= counter + 1

What I get now is the all records have a 1 instead of incremented value.

I would like fielda to contain the new value for each row read.

thanks in advance,


Question by:dprice7
    LVL 75

    Accepted Solution

    In order to do that you will need to define a global variable, set its initial value (see the Package Properties) and change your ActiveX Script as follows:

    DTSGlobalVariables("YourCounterNameGoesHere").Value = DTSGlobalVariables("YourCounterNameGoesHere").Value + 1
    DTSDestination("fielda") = DTSGlobalVariables("YourCounterNameGoesHere").Value
    LVL 6

    Assisted Solution

    You would have to use the global variable (i.e. declared on a DTS package level) in your ActiveX script. Otherwise the locally declared variable is initalised for each row read (as the ActiveX script is stateless and called separatelly for each row).
    LVL 30

    Expert Comment

    If you're interested there may be a way to do this without code using an IDENTITY field.

    Author Comment

    I want to split the points so I can split them.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
    Introduction In my previous article ( I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
    Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
    Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now