dbTalk Databases Forums  

Create a Dynamic file name with ActiveX script

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Create a Dynamic file name with ActiveX script in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
LionsDome
 
Posts: n/a

Default Create a Dynamic file name with ActiveX script - 12-14-2006 , 08:17 AM






Hello,

I am trying to create a file name that puts in the current date and
time at the time of creation. I am able to create it just fine without
the date and time stamp but not with it. Can someone out there tell me
what I am doing wrong? I keep getting a type mismatch error. I think
the problem is somewhere with the DTSGlobalVariables. Code is attached
-

Function Main()
dim fso
dim FileName

set fso = CREATEOBJECT("Scripting.FileSystemObject")

FileName = "C:\test " & Date & " " & Time &".txt"

DTSGlobalVariables(FileName).Value

fso.CreateTextFile FileName

set fso = Nothing

Main = DTSTaskExecResult_Success

End Function

Thanks.


Reply With Quote
  #2  
Old   
Cédric Del Nibbio
 
Posts: n/a

Default Re: Create a Dynamic file name with ActiveX script - 12-14-2006 , 11:47 AM






Hi,

the matter is that you can't create a file with some special characters
in it such as "/" and ":".
Thus, you should replace these characters...

As an example, your filename could be the following :
FileName = "C:\test " & Replace(Date, "/", "-") & " " & Replace(Time,
":", "-") & ".txt"

This should solve your problem.

Cédric Del Nibbio
MCP since 2003
MCAD .Net
MCTS SQL Server 2005

LionsDome a écrit :

Quote:
Hello,

I am trying to create a file name that puts in the current date and
time at the time of creation. I am able to create it just fine without
the date and time stamp but not with it. Can someone out there tell me
what I am doing wrong? I keep getting a type mismatch error. I think
the problem is somewhere with the DTSGlobalVariables. Code is attached
-

Function Main()
dim fso
dim FileName

set fso = CREATEOBJECT("Scripting.FileSystemObject")

FileName = "C:\test " & Date & " " & Time &".txt"

DTSGlobalVariables(FileName).Value

fso.CreateTextFile FileName

set fso = Nothing

Main = DTSTaskExecResult_Success

End Function

Thanks.


Reply With Quote
Reply




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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.