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!

Invalid Task Result value in SQL Server 2000

Status
Not open for further replies.

ksar

IS-IT--Management
Nov 21, 2003
2
US
Hello all,
I am getting a Invalid Task Result error when running this script in SQL Server 2000 see below

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

option explicit
on error resume next
'Since this was written for Windows Scri
' pting Host,
'it uses VBScript which doesn't use type
' s.
'To use this with VB, as types to the de
' clarations
dim objFSO 'as FileSystemObject
dim fle1 'as file
dim fle2 'as file
dim strPath 'as string
dim strFldr 'as string
dim strLine 'as string
' strPath = "C:FirstFile.txt" 'Put in the file you want to edit
'strFldr = "C:TempFile.txt"
strPath = "\\Asussdak1210s\droot\Comet\Khone\ManTest.txt"
strFldr = "\\Asussdak1210s\droot\Comet\Khone\TempFile.txt"

Main

sub Main()
dim rtn 'as integer
rtn = CopyStuff() 'This calls and runs the CopyStuff function
if rtn = 1 then
msgbox "Copy is complete"
else
msgbox "An error was found and the process was aborted. " & Cstr(rtn)
'The & Cstr(rtn) will display the number returned by CopyStuff
'After you've got your script running, you may want to remove this feature
end if
'Cleanup
if not fle1 is nothing then set fle1 = nothing
if not fle2 is nothing then set fle2 = nothing
if not objFSO is nothing then set objFSO = nothing
end sub


function CopyStuff()
set objFSO = CreateObject("Scripting.FileSystemObject") 'This creates the FSO
'I've included error handling after each step
if err.number <> 0 then
msgbox &quot;Error in Creating Object: &quot; & err.number & &quot;; &quot; & err.description
CopyStuff = 0 'Returns this number
exit function 'Stop processing, go back to Main
end if
if not objFSO.FileExists(strPath) then 'The file to copy is not present
msgbox &quot;The &quot; & strPath & &quot; file was not found on this computer&quot;
CopyStuff = 2
exit function
end if
if objFSO.FileExists(strFldr) then
objFSO.DeleteFile(strFldr) 'If the temp file is found, delete it
end if
set fle1 = objFSO.OpenTextFile(strPath) 'Open
if err.number <> 0 then
msgbox &quot;Error opening &quot; & strPath & &quot;: &quot; & err.number & &quot;; &quot; & err.description
CopyStuff = 3
exit function
end if
set fle2 = objFSO.CreateTextFile(strFldr) 'Create the temp file
if err.number <> 0 then
msgbox &quot;Error creating temp ini: &quot; & err.number & &quot;; &quot; & err.description
CopyStuff = 4
exit function
end if
'Here's the work horse that does the copying
Do while not fle1.AtEndofStream 'Change this line, Change this one too
strLine = fle1.ReadLine
select Case strLine
case &quot;Change this line&quot;
'When the above line is found, it is replaced with the line below
fle2.WriteLine &quot;Changed&quot;
case &quot;Change this one too&quot;
fle2.WriteLine &quot;This line is changed&quot;
case else
'This copies whatever was read in fle1
fle2.WriteLine strLine
end select
loop
if err.number <> 0 then
msgbox &quot;Error transfering data: &quot; & err.number & &quot;; &quot; & err.description
CopyStuff = 5
fle1.close
fle2.close
exit function
end if

fle1.close
set fle1 = nothing
fle2.close
set fle2 = nothing

objFSO.DeleteFile strPath, true 'This deletes the original file

objFSO.MoveFile strFldr, strPath 'This moves and renames the temp file, replacing the original
if err.number <> 0 then
msgbox &quot;Error replacing &quot; & strPath & &quot; with new file: &quot; & err.number & &quot;; &quot; & err.description
CopyStuff = 6
else
CopyStuff = 1 'Remember that in Main, a 1 means successful
end if
end function

please help
Thanks in advance
 
For activex it usually started and ended like this

Function Main()

<<.....VB Scripts portion....>>

Main = DTSTaskExecResult_Success (This part can modified accordingly)
End Function

But I didnt see any of them included in ur ActiveX coding.
 
Thanks for the suggestion but I have resolved it...You are correct...I had to return it from the sub main


Ksar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top