Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Bizarre Behavior of ActiveX Script Task

Author  Topic 

Wyatt70
Starting Member

6 Posts

Posted - 2005-03-04 : 14:36:17
I have a DTS Package with an ActiveX Script Task. Here is the script:


Function Main()
Dim objFSO, strShortDate, strMonth, strDay, strYear, strDateText
Dim strFileName, strNewFileName, objFile

Set objFSO = CreateObject("Scripting.FileSystemObject")


strShortDate = CStr(Replace(FormatDateTime(date, 2),"/",""))

strDay = LEFT(strShortDate, 2)
strMonth = MID(strShortDate, 3, 2)
strYear = RIGHT(strShortDate, 4)

strDateText = strYear & strDay & strMonth

strFileName = objFSO.GetFileName("C:\BURS_Documentation\BusinessUpdateReport_New.xls")

strNewFileName = REPLACE(strFileName,"New",strDateText)

Set objfile = objFSO.GetFile("C:\BURS_Documentation\" & strFileName)
objFile.Copy("C:\BURS_Documentation\" & strNewFileName)

strFilePath = "C:\BURS_Documentation\" & strNewFileName

DTSGlobalVariables("ParentFileName").value = strFilePath

Set objFSO = Nothing

Main = DTSTaskExecResult_Success
End Function


If I run this directly from SQL Server, it works correctly. If I run it from an aspx page, the file name is incorrect.

For example:

If I run the package on March 4, 2005, the resulting file name should be "BusinessUpdateReport_20050304.xls". When I run directly from SQL Server, this is the name that I get.

If I run from the aspx page using the LoadFromSQLServer method, here is the resulting file name:

"BusinessUpdateReport_20053420.xls".

Anyone have any idea why this would be happening?

EdGruberman
Starting Member

2 Posts

Posted - 2005-03-07 : 13:49:57
Odd indeed. I'm not familiar enough with the LoadFromSQLServer method to know what environment changes occur, so I won't be much help there. However, maybe a different approach is in order?

Try the following perhaps:
strDateText = Year(Now) & Day(Now) & Month(Now)

Cut's down on code too! :) Just a guess though.
Go to Top of Page
   

- Advertisement -