Subject: RE: Agent RunOnServer Hangs connecting to DB2
Before trying to schedule the agent, we set the agents security options to “Run with full Administrator rights”, and had the agent signed by the Notes admin. Yet, the agent still failed.
When we scheduled the agent we ran it signed by a developers id and it ran OK. There are no drive mappings or attempted I/O’s to the file system inside the agent.
Here is the agent :
===========================
Sub Initialize
Print “Starting DB2 Insert Agent”
Dim session As New NotesSession
Dim doc As NotesDocument
Dim pdoc As NotesDocument
Dim db As NotesDatabase
Dim agent As NotesAgent
Set con = New ODBCConnection
Print “Connect ODBC”
Set query = New ODBCQuery
Set data = New ODBCResultSet
Set db = session.CurrentDatabase
Set agent = session.CurrentAgent
Set pdoc = db.GetDocumentByID (agent.ParameterDocID)
Set doc = db.GetDocumentByUNID(pdoc.DocId(0))
Set query.connection = con
Set data.query = query
Print “About to connect to CNSW44.CNSNWI”
If Not con.ConnectTo(DB2DB, UID, PWD) Then
Print "Could not connect to DSNU"
Exit Sub
End If
Print “Connected to DSNU”
sql = "Insert into CNSW44.CNSNWI (CPY_CD, DOC_ID, MTN_TYP, FAC_WHS, BYR_CD, VEN_NBR, " & _
"RTL_UNT_STR_CSE, ITM_SIZ_DSC, ITM_DSC, CSE_LEN, CSE_WDT, CSE_HGT, CSE_WGT, " &_
"CSE_PER_LAY, LAY_PER_PAL, LA_TAX_FLD, TX_TAX_FLD, PPR_FLD, BON_PAC_FLD, " &_
"EST_ARR_DT, FRT_ALW_TYP, FRT_ALW, CSE_CST, CSE_GTIN, PRD_GTIN) " &_
"values('G', '" & doc.UniversalID & "','N', ' ', '" & _
doc.GSCBuyerCode(0) & "','" & doc.VendorNumber(0) & "'," & doc.BPack(0) & ",'" & doc.BSize(0) & "','" &_
doc.BDesc(0) & "','" & doc.BCaseLength(0) & "','" & doc.BCaseWidth(0) & "','" & doc.BCaseHeight(0) & "','" &_
doc.BCaseWeight(0) & "','" & doc.BTI(0) & "','" & doc.BHI(0) & "','" & doc.BLaTaxable(0) & "','" &_
doc.BTaxable(0) & "','" & doc.BPrePriced(0) & "','" & doc.BBonusPack(0) & "','" & doc.BArrivalDate(0) & "','" &_
doc.BAllowType(0) & "','" & doc.BAllowance(0) & "','" & doc.BPOCost(0) & "','" & doc.BCaseGTIN(0) & "','" &_
doc.BProdGTIN(0) & "')"
query.sql = sql
REM Msgbox sql,“Test”
If Not data.Execute Then
Print "Not OK, Could not Connect!"
error% = data.GetError
message$ = data.GetErrorMessage(error%)
ExtendedMessage$=data.GetExtendedErrorMessage(error%)
Print message$
Print "Error Code: " & Str$(error%)
Print "Extended Error: " & ExtendedMessage$
Exit Sub
End If
End Sub