Re: SQL Passthru- Insert and Update

From: Kam (Kam_at_discussions.microsoft.com)
Date: 02/04/05


Date: Thu, 3 Feb 2005 21:55:01 -0800

No error come out.
My code is as follow.

ON ERROR Do errhand

                        CLEAR
                        CLEAR ALL
                        
                        STORE SQLCONNECT('SystenDSN', '', '') TO gnConnHandle
                        IF gnConnHandle <= 0
                                ? 'Connection Failed - SystemDSN'
                        ELSE
                                ? 'Connection Success - SystemDSN'
                        ENDIF
                        nSet = SQLSETPROP(gnConnHandle, "Asynchronous", .f.)
                        ? "nSet = " + STR(nSet)
                        
                        cSQL = ''
                        cSQL = cSQL + "Insert into sgawebsystemcitibank.tReqHeader (ReqStatus) "
                        cSQL = cSQL + "Values "
                        cSQL = cSQL + "("+TTOC(DATETIME())+","+"'QUEUE')"
                                                
                        ?cSQL
                        pCursor = 'SQLResult'
                        nSQLExec = 0
                        DO WHILE nSQLExec = 0
                                ?TIME()
                                nSQLExec= SQLEXEC(gnConnHandle, cSQL)
                                ?nSQLExec
                        ENDDO
                        =SQLDISCONNECT(gnConnHandle)
RETURN

PROCEDURE errhand
        =AERROR(aErrorArray)
        CLEAR
        ?'The error provided the following information'
        FOR n=1 TO 7
                ?aErrorArray(n)
        endfor
RETURN

"Fred Taylor" wrote:

> You need to find out what it doesn't like. Use the AERROR() function to see
> what kind of error you're getting in your SQLEXEC call.
>
> --
> Fred
> Microsoft Visual FoxPro MVP
>
>
> "Kam" <Kam@discussions.microsoft.com> wrote in message
> news:AE681036-F4BD-4F4E-B776-99FDBAE9A579@microsoft.com...
> >I am using SQL Passthru to update a free table, I create the DSN name under
> > system DSN.
> >
> > STORE SQLCONNECT('SystemDSN', '', '') TO gnConnHandle
> > IF gnConnHandle <= 0
> > ? 'Connection Failed - SGAWebSystemCitiBank'
> > ELSE
> > ? 'Connection Success - SGAWebSystemCitiBank'
> > ENDIF
> > nSet = SQLSETPROP(gnConnHandle, "Asynchronous", .f.)
> >
> > cSQL = ''
> > cSQL = cSQL + 'Insert Into tReqHeader '
> > cSQL = cSQL + '(ReqID) '
> > cSQL = cSQL + 'Values '
> > cSQL = cSQL + '('+ TTOC(DATETIME()) + ')'
> >
> > nSQLExec = 0
> > DO WHILE nSQLExec = 0
> > ?TIME()
> > nSQLExec = SQLEXEC(gnConnHandle, cSQL)
> > ?nSQLExec
> > ENDDO
> >
> > but nSQLEXec always return -1, so the record didn't added.
> >
> > please help and one of the field in the table is datetime(), how can I
> > create the query to perform the update.
>
>
>