Hi,
I have written active script in SQL Server Agent job to
connect to a FTP site using third party FTP/X control.
When I run the job, I get an error as "ActiveScripting
specific error 257 occurred. The step failed".
I tried using the same piece of code in VB 6.0 and its
working fine.
Any advice will be appreciated. Thanks.
regards,
Hemansu
The error is usually due to threading issues. SQL Server,
SQL Agent are multithreaded processes and more than one
thread can access the object. The object may not be able to
handle that due to the threading model it was written under.
Try using a CmdExec step instead of an ActiveX script job
step as CmdExec job steps run in their own thread. You could
write the code to a VB Script file and then execute that
script using CmdExec, e.g.
csript c:\YourScript.vbs
-Sue
On Thu, 9 Sep 2004 16:26:36 -0700, "Hemansu Amin"
<hemansu_amin@.yahoo.com> wrote:
>Hi,
>I have written active script in SQL Server Agent job to
>connect to a FTP site using third party FTP/X control.
>When I run the job, I get an error as "ActiveScripting
>specific error 257 occurred. The step failed".
>I tried using the same piece of code in VB 6.0 and its
>working fine.
>Any advice will be appreciated. Thanks.
>regards,
>Hemansu
|||Thanks Sue. It works!!!
>--Original Message--
>The error is usually due to threading issues. SQL Server,
>SQL Agent are multithreaded processes and more than one
>thread can access the object. The object may not be able
to
>handle that due to the threading model it was written
under.
>Try using a CmdExec step instead of an ActiveX script
job
>step as CmdExec job steps run in their own thread. You
could
>write the code to a VB Script file and then execute that
>script using CmdExec, e.g.
>csript c:\YourScript.vbs
>-Sue
>On Thu, 9 Sep 2004 16:26:36 -0700, "Hemansu Amin"
><hemansu_amin@.yahoo.com> wrote:
>
>.
>
|||Your welcome Hemansu and thanks for posting back that it worked. It
always helps to get verification when something helps work around an
issue.
-Sue
On Thu, 9 Sep 2004 20:37:38 -0700, "Hemansu Amin"
<hemansu_amin@.yahoo.com> wrote:
[vbcol=seagreen]
>Thanks Sue. It works!!!
>
>to
>under.
>job
>could
Showing posts with label ftp. Show all posts
Showing posts with label ftp. Show all posts
Thursday, March 22, 2012
Tuesday, March 20, 2012
Active X script help in a DTS package
I have a file that gets placed on our ftp site once a week. The file is named achconsxx.dat
The xx is the fiscal week meaning the file one week looks like achcons18.dat and the next week it will look like achcons19.dat
I am trying use an ActiveX script in my DTS package to unzip that file and rename to achcons.dat so I can import.
My code looks like this so far:
Function Main()
Dim objWshshell, objFso
Dim strCmd, strSubject, strMessage, strFileattachment, rc
DTSGlobalVariables("gv_strWklydir").value = "\\E$\Update\Data\" ' Weekly directory
DTSGlobalVariables("gv_strACHFile").value = "achcons" & DTSGlobalVariables("gv_strFW").value & ".zip" ' ACH Group weekly file
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objWshshell = CreateObject("WScript.Shell")
rc = 0
' Build the Winzip command
If (objFso.FileExists(DTSGlobalVariables("gv_strWklydir").value & DTSGlobalVariables("gv_strACHFile").value)) Then
strCmd = "winzip32.exe -e -o " & DTSGlobalVariables("gv_strWklydir").value &_
DTSGlobalVariables("gv_strACHFile") & " " & DTSGlobalVariables("gv_strWklydir").value
rc = objWshshell.Run(strCmd, 1, true)
If (objFso.FileExists(DTSGlobalVariables("gv_strWklydir").value & objFso.GetBaseName(DTSGlobalVariables("gv_strACHFile")) & ".dat")) Then
objFso.GetFile(DTSGlobalVariables("gv_strWklydir").value & objFso.GetBaseName(DTSGlobalVariables("gv_strACHFile")) & ".dat").Copy (DTSGlobalVariables("gv_strWklydir").value & "achcons.dat")
End If
Set objWshshell = Nothing
Set objFso = Nothing
End If
I also have an e-mail routine that sends me an e-mail if the file doesn't exist. The e-mail works so my code can't see the file it needs to unzip and rename.
Any help is appreciated.May refer to http://www.sqldts.com for any reference on activex using in DTS.
The xx is the fiscal week meaning the file one week looks like achcons18.dat and the next week it will look like achcons19.dat
I am trying use an ActiveX script in my DTS package to unzip that file and rename to achcons.dat so I can import.
My code looks like this so far:
Function Main()
Dim objWshshell, objFso
Dim strCmd, strSubject, strMessage, strFileattachment, rc
DTSGlobalVariables("gv_strWklydir").value = "\\E$\Update\Data\" ' Weekly directory
DTSGlobalVariables("gv_strACHFile").value = "achcons" & DTSGlobalVariables("gv_strFW").value & ".zip" ' ACH Group weekly file
Set objFso = CreateObject("Scripting.FileSystemObject")
Set objWshshell = CreateObject("WScript.Shell")
rc = 0
' Build the Winzip command
If (objFso.FileExists(DTSGlobalVariables("gv_strWklydir").value & DTSGlobalVariables("gv_strACHFile").value)) Then
strCmd = "winzip32.exe -e -o " & DTSGlobalVariables("gv_strWklydir").value &_
DTSGlobalVariables("gv_strACHFile") & " " & DTSGlobalVariables("gv_strWklydir").value
rc = objWshshell.Run(strCmd, 1, true)
If (objFso.FileExists(DTSGlobalVariables("gv_strWklydir").value & objFso.GetBaseName(DTSGlobalVariables("gv_strACHFile")) & ".dat")) Then
objFso.GetFile(DTSGlobalVariables("gv_strWklydir").value & objFso.GetBaseName(DTSGlobalVariables("gv_strACHFile")) & ".dat").Copy (DTSGlobalVariables("gv_strWklydir").value & "achcons.dat")
End If
Set objWshshell = Nothing
Set objFso = Nothing
End If
I also have an e-mail routine that sends me an e-mail if the file doesn't exist. The e-mail works so my code can't see the file it needs to unzip and rename.
Any help is appreciated.May refer to http://www.sqldts.com for any reference on activex using in DTS.
Subscribe to:
Posts (Atom)