Hi,
My script below only sends through the first item in each document. When I debug the script, it shows that it goes through every single one of the items, but it doesn’t record it on the external database, it only records the first item.’
I have checked the DATASOURCE Properties and all is fine. Any suggestions?
***** Script *****
Sub Initialize
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument
Dim doc As NotesDocument
Set doc = uidoc.Document
Dim seq_id As Variant
Dim reqno As Variant
Dim itemno As Variant
Dim translatedqty As Variant
Dim itemdesc As Variant
Dim con As New ODBCConnection
Dim qry As New ODBCQuery
Dim res As New ODBCResultSet
Dim retcode As Integer
retcode%=con.ConnectTo("DATASOURCE","USERNAME","PASSWORD")
If (retcode% = False) Then
Msgbox "Could not connect to datasource: DATASOURCE"
Exit Sub
End If
Set qry.connection = con
qry.SQL = "SELECT REQNO, ITNBR, QTYOR, ITDSC FROM REQHDF"
Set res.Query = qry
res.execute
counter = 0
seq_id = doc.getitemvalue("seq_id")
reqno = doc.getitemvalue("reqno")
itemno = doc.getitemvalue("itemno")
translatedqty = doc.getitemvalue("translatedqty")
itemdesc = doc.getitemvalue("itemdesc")
Forall items In seq_id
res.addrow
Call res.SetValue("REQNO", reqno(0))
Call res.SetValue("ITNBR", itemno(counter))
Call res.SetValue("QTYOR", translatedqty(counter))
Call res.SetValue("ITDSC", itemdesc(counter))
res.updaterow
counter=counter+1
End Forall
res.close(DB_CLOSE)
con.disconnect
End Sub