Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Wwhttpsql is posting each record twice to web server
Message
General information
Forum:
Visual FoxPro
Category:
West Wind Web Connection
Title:
Wwhttpsql is posting each record twice to web server
Miscellaneous
Thread ID:
00888061
Message ID:
00888061
Views:
61
The following code works--sort of. It uploads invoice detail records to the server just fine. The problem is, it's posting two records to the server for every record in the local cursor.

(We're running Version 4.25 of the West-Wind Client Tools). Am I doing something wrong?

Thanks in advance for your assistance.
LOCAL llContinue, lcSQLstr, lnCount, lcStr, jnX
STORE .T. TO llContinue

oHSQL = NEWOBJECT("wwHTTPSQL","wwhttpsql.prg")
oHSQL.cServerUrl = gcServerUrl
oHSQL.nConnectTimeout = 5
oHSQL.cSQLCursor = "cTemp"  && Specify the result cursor name

llContinue = VARTYPE(oHSQL) = "O"

* Update invdetl.dbf records
*********************************************************************

IF llContinue

 jnX = 0

 SELECT cInvDetl
 GO TOP
 DO WHILE NOT EOF()

  jnX = jnX + 1
  lcSQLstr = [INSERT INTO invdetl ( ]
  lcSQLstr = lcSQLstr + [dWorkDone,nHours,nMinutes,yRatePerHr,yItemAmt,cSubject,nInvDseq,]
  lcSQLstr = lcSQLstr + [nID,ninvoiceid,nuserid,cAsnName,nclientid,ntaskid,nrequserid,ncatid,]
  lcSQLstr = lcSQLstr + [cCategory,nsubcatid,cSubCat,dtinvoice,dateadded,dtlastupdt,username,machine)]
  lcSQLstr = lcSQLstr + [ VALUES ( ]
  lcSQLstr = lcSQLstr + DTOSTRICT(dWorkDone) + [,]
  lcSQLstr = lcSQLstr + ALLTRIM(STR(nHours)) + [,]
  lcSQLstr = lcSQLstr + ALLTRIM(STR(nMinutes)) + [,]
  lcSQLstr = lcSQLstr + ALLTRIM(STR(yRatePerHr,12,4)) + [,]
  lcSQLstr = lcSQLstr + ALLTRIM(STR(yItemAmt,12,4)) + [,]
  lcSQLstr = lcSQLstr + ['] +ALLTRIM(cSubject) + [',]
  lcSQLstr = lcSQLstr + ALLTRIM(STR(nInvDseq)) + [,]
  lcSQLstr = lcSQLstr + ALLTRIM(STR(nID)) + [,]
  lcSQLstr = lcSQLstr + ALLTRIM(STR(ninvoiceid)) + [,]
  lcSQLstr = lcSQLstr + ALLTRIM(STR(nuserid)) + [,]
  lcSQLstr = lcSQLstr + ['] + ALLTRIM(cAsnName) + [',]
  lcSQLstr = lcSQLstr + ALLTRIM(STR(nClientID)) + [,]
  lcSQLstr = lcSQLstr + ALLTRIM(STR(nTaskID)) + [,]
  lcSQLstr = lcSQLstr + ALLTRIM(STR(nReqUserID)) + [,]
  lcSQLstr = lcSQLstr + ALLTRIM(STR(nCatid)) + [,]
  lcSQLstr = lcSQLstr + ['] + ALLTRIM(cCategory) + [',]
  lcSQLstr = lcSQLstr + ALLTRIM(STR(nSubCatid)) + [,]
  lcSQLstr = lcSQLstr + ['] + ALLTRIM(cSubCat) + [',]
  lcSQLstr = lcSQLstr + DTOSTRICT(dtInvoice) + [,]
  lcSQLstr = lcSQLstr + DTOSTRICT(dateAdded) + [,]
  lcSQLstr = lcSQLstr + DTOSTRICT(dtLastUpdt) + [,]
  lcSQLstr = lcSQLstr + ['] + ALLTRIM(username) + [',]
  lcSQLstr = lcSQLstr + ['] + ALLTRIM(machine) + [')]

  IF llContinue
   THISFORM.lblStatus.CAPTION = "Saving invoice detail record #"    + ALLTRIM(STR(jnX))
   lnCount = oHSQL.Execute(lcSQLstr)
  ENDIF && llContinue

  IF llContinue
   IF oHSQL.lError
    llContinue = .F.
    MESSAGEBOX(oHSQL.cErrorMsg)
   ENDIF
  ENDIF && llContinue

  IF llContinue
   lcStr = ALLTRIM(cInvDetl.cDetail)
   lcSQLstr = oHSQL.AddSqlParameter("parmDescript",lcStr)
   oHSQL.Execute([UPDATE invdetl SET cDetail=parmDescript where ninvoiceid=] + ALLTRIM(STR(ninvoiceid))  )
  ENDIF && llContinue

  IF llContinue
   IF oHSQL.lError
    llContinue = .F.
    MESSAGEBOX(oHSQL.cErrorMsg)
   ENDIF
  ENDIF && llContinue

  IF llContinue

   SELECT cInvDetl
   IF NOT EOF('cInvDetl')
    SKIP IN cInvDetl
   ENDIF
  ENDIF && llContinue

 ENDDO && while not eof()

ENDIF && llContinue

*********************************************************************
* Done updating invdetl.dbf


RELEASE oHSQL
CLEAR CLASS wwhttpsql
David Martin
Reply
Map
View

Click here to load this message in the networking platform