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 23rd, 2004, 11:27 AM
Friend of Wrox
 
Join Date: Nov 2003
Location: Lehigh Acres, FL, USA.
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default DTS Visual Basic ActiveX Script

[u]This is a two part question.. Part I</u>Can someone help with this issue. See script below.  I will like to add at the point of creating this file to increment the text file generated by (1) each time the DTS Package runs, for example: At 12:00 PM a file is created (20040423_trans.txt)then it is run again at 12:15 PM,  I will like to keep the same file name structure for that day and increase the count to specify the amount of time it was run ex: 20040423_trans_01.txt, 20040423_trans_02.txt, etc.,  Any and all help will be appreciated.

'************************************************* *********************
'  Visual Basic ActiveX Script
'************************************************* ***********************


Option Explicit

Function Main()

            Dim oConn, sFilename

 

            ' Filename format - yymmdd_webcredits.txt
            sFilename =  Right(DAY(Now()), 10) &"_"&"webcredits"
            If Month(Now()) < 10 Then sFilename =  "0" & _
                Month(Now()) & sFilename Else sFilename = DAY(Now()) & sFilename
            If Day(Now()) < 10 Then sFilename =  _
                "0" & month(Now()) & sFilename Else sFilename =  YEAR(Now()) & sFilename
            sFilename = DTSGlobalVariables("LogFilePath").Value & _
                sFilename & ".txt"

 

            Set oConn = DTSGlobalVariables.Parent.Connections("Text File (Destination)")
            oConn.DataSource = sFilename
            Set oConn = Nothing
            Main = DTSTaskExecResult_Success

End Function

Part II

How do I set the file path using the global variable

sFilename = DTSGlobalVariables("LogFilePath").Value & _
                sFilename & ".txt"
__________________
Jaime E. Maccou
  #2 (permalink)  
Old April 27th, 2004, 12:01 AM
Registered User
 
Join Date: Apr 2004
Location: Gilbert, AZ, USA.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to bizzeau Send a message via MSN to bizzeau
Default

Ok, this should solve both of your questions.  I've created a little sample script for you that you can use to determine what properties exist for a given connection.  You can then manipulate and modify these properties by using them the same what I've displayed them.

Create a DTS package with 1 ActiveX Script Task and one generic Text File Destination connection (mine is named "Sample").  Load this script into your ActiveX Script Task:

Function Main()
    dim sfilename, x, y

    dim objpkg
    set objpkg = dtsglobalvariables.parent

    y = "DTS Package Connection (Sample) Properties" & vbcrlf & vbcrlf

    for x = 1 to objpkg.connections("Sample").properties.count
        y = y & objpkg.connections("Sample").properties(x).name & ": " & objpkg.connections("Sample").properties(x).value & vbcrlf
    next

    msgbox y

    sfilename = objpkg.connections("Sample").properties("DataSourc e").value
    msgbox "Current File Name: " & sfilename

    sfilename = "C:\Testing.txt"
    msgbox "Changed File Name: " & sfilename

    objpkg.connections("Sample").properties("DataSourc e").value = sfilename

    msgbox "Filename set to new value: " & objpkg.connections("Sample").properties("DataSourc e").value

    set objpkg = nothing
    Main = DTSTaskExecResult_Success
End Function


Run that script, and it'll go through and display, change, and set a new "DataSource" for your Text File Destination connection.  Let me know if you have any questions - bizzeau@hotmail.com - I've been working with DTS for just shy of FOREVER... ;)

Thanks,
Beau Frusetta
DBA/Developer
  #3 (permalink)  
Old April 27th, 2004, 03:02 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: Lehigh Acres, FL, USA.
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

I tried your recommended script but it did not work for me. Attached in the Dts package I created with your script. I keep getting the error "sample" was not found. I created a sample text destination. Please let me know what you think.


  #4 (permalink)  
Old November 7th, 2007, 12:13 PM
Registered User
 
Join Date: Nov 2007
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is "Sample" supposed to be the name of the server and DataSource the name of the database? I get the same error. This is a bit vague, can you please explain? THANK YOU!!!! :)

  #5 (permalink)  
Old November 28th, 2007, 06:11 PM
Friend of Wrox
 
Join Date: Nov 2003
Location: Lehigh Acres, FL, USA.
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

wow, this is very old and it has been resolved. Thank you answering.

Jaime E. Maccou
 


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 - formatting excel sheet using activex script Najmunnisha SQL Server DTS 2 May 17th, 2007 11:27 PM
DTS and ActiveX VB Script gscott SQL Server DTS 6 May 16th, 2007 08:38 AM
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 09:41 AM



All times are GMT -4. The time now is 03:42 PM.


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