Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DTS ActiveX Task

Status
Not open for further replies.

Rhys666

Programmer
May 20, 2003
1,106
OK. I have a DTS Package that takes dynamic properties from an ini file, and exoprts two tables as flat csv files to a server location. They are the only files within this location.

I have now been asked to append a Date and time stamp to these files, after the data. Basically, after the tables have been exported I need to open each file in the network path and append a string value of 'Date and Time Created:' and the current Datetime to the end of the file.

I know this must be possible with an ActiveX task, and the FileSystemObject, but after having been solely working in c# and ASP.net for just over a year my VB is very,, very poor.

Can anyone help me to be able to get this right?

The path of the folder I can get to a Global variable without a problem, so I need to work out how to use the FileSystemObject to open each file in the location in the string DTS Global Variable holding the value of the path, and then append a string value and the current DateTime to the end of the file, preceded by a line break.

Advice, pointers or solutions accepted willingly.

Rhys

Be careful that the light at the end of the tunnel isn't a train coming the other way.
 
Hi Rhys

In a ActiveX task you can use either

* VB Script
* JScript

So you will have something like this.

Dim fs
Dim a

Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.OpenTextFile("Filename",ForAppending,False)
a.WriteLine("DateTimeStamp")
a.Close

set a = nothing
set fso = nothing

You might want to check out the OpenTextFile Method of the File System Object to see if the parameters are as you require them.

Hope this helps
[flowerface]



"All I ask is the chance to prove that money can't make me happy." - Spike Milligan
 
Cheers v.much, my VB has degraded significantly since I havn't written any in iver 18 months! Anyway, problem resolved, VBScript below if anyone is interested...

Code:
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso
Dim f

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(DTSGlobalVariables("gv_TextPath").Value, ForAppending, True)

f.WriteLine ("DateTime Created:," & Now)
f.Close
Set f = Nothing
Set fso = Nothing

Main = DTSTaskExecResult_Success

Rhys

Be careful that the light at the end of the tunnel isn't a train coming the other way.
 
I have been able to do what you just described, but I am unable to schedule the DTS as a job. It fails everytime.

Did you schedule this job and if you did, how did you do it?

Denis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top