I've got a script that queries the database via a command, updates a text file, and then emails the file. I've got a timeout set to 200, but once and a while it will run for days without timeing out. Can any body spot the issue?...Here's the basic code...
'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************
Function Main()
Dim i,Conn,RS
Set Conn = CreateObject("ADODB.Connection")
Conn.CommandTimeout = 200
Set objCmd = createobject("ADODB.Command")
Source=ConnectionString
Conn.Open (ConnectionString)
set objCmd.activeconnection = Conn
objCmd.CommandTimeout = 200
objCmd.CommandText = "sp_myproc"
objCmd.CommandType = &H0004
objCmd.Parameters.Append objCmd.CreateParameter("@var1", 5, &H0004, 3) 'double return
Set RS = objCmd.Execute
Set RS = RS.NextRecordset
wVar1 = objCmd.Parameters("@cnt_var1").Value
Conn.close
set Conn = nothing
set RS = nothing
set objCmd = nothing
Set objFSO = CreateObject("Scripting.FileSystemObject")
wPath = mypath
Set TargetFile = objFSpenTextFile (wPath,8 ,True)
TargetFile.Write (wVar1 )
TargetFile.close
Set TargetFile = nothing
set objFSO = nothing
Dim objCDO
Set objCDO = CreateObject("CDO.Message")
if isobject(objCDO) then
objCDO.To = "me@mydomain.com"
objCDO.From = "me@mydomain.com"
objCDO.AddAttachment(mypath)
objCDO.Configuration.Fields.Item (" = 2
objCDO.Configuration.Fields.Item (" = "myip"
objCDO.Configuration.Fields.Item (" = 25
objCDO.Configuration.Fields.Update
'objCDO.Send
Set objCDO = Nothing
else
msgBox "mail Error: "
end if
Main = DTSTaskExecResult_Success
End Function
'**********************************************************************
' Visual Basic ActiveX Script
'************************************************************************
Function Main()
Dim i,Conn,RS
Set Conn = CreateObject("ADODB.Connection")
Conn.CommandTimeout = 200
Set objCmd = createobject("ADODB.Command")
Source=ConnectionString
Conn.Open (ConnectionString)
set objCmd.activeconnection = Conn
objCmd.CommandTimeout = 200
objCmd.CommandText = "sp_myproc"
objCmd.CommandType = &H0004
objCmd.Parameters.Append objCmd.CreateParameter("@var1", 5, &H0004, 3) 'double return
Set RS = objCmd.Execute
Set RS = RS.NextRecordset
wVar1 = objCmd.Parameters("@cnt_var1").Value
Conn.close
set Conn = nothing
set RS = nothing
set objCmd = nothing
Set objFSO = CreateObject("Scripting.FileSystemObject")
wPath = mypath
Set TargetFile = objFSpenTextFile (wPath,8 ,True)
TargetFile.Write (wVar1 )
TargetFile.close
Set TargetFile = nothing
set objFSO = nothing
Dim objCDO
Set objCDO = CreateObject("CDO.Message")
if isobject(objCDO) then
objCDO.To = "me@mydomain.com"
objCDO.From = "me@mydomain.com"
objCDO.AddAttachment(mypath)
objCDO.Configuration.Fields.Item (" = 2
objCDO.Configuration.Fields.Item (" = "myip"
objCDO.Configuration.Fields.Item (" = 25
objCDO.Configuration.Fields.Update
'objCDO.Send
Set objCDO = Nothing
else
msgBox "mail Error: "
end if
Main = DTSTaskExecResult_Success
End Function