General information
Category:
Coding, syntax & commands
Title:
Connecting to SQL and retrieving data
Environment versions
Network:
Windows 2003 Server
I'm trying to flag a record as being undelete and if update occurred, I pass back the number of records updated. In foxpro I call a stored procedure passing through the client code to be flagged as undeleted. In my code it returns 0 even if record is updated. Why?
--------------foxpro------------------------
LOCAL lcStoreProc, lcGrower, lcReason
lcStoreProc = "bk_undelete_prod"
lcGrower = ALLTRIM(thisform.Grower)
lcReason = ALLTRIM(thisform.Reason)
*!* Create connection to SQL database and retreive data
LOCAL loConn AS ADODB.CONNECTION, loCommand AS ADODB.COMMAND, loException AS EXCEPTION, laErrors[1]
PUBLIC loCursor AS CURSORADAPTER
SET MULTILOCKS ON
SET ASSERTS ON
ASSERT .F.
lcFile = "FILE NAME=" + "W:\BKB Development\CCDBaddon\ccdbaddon.udl"
loConn = NEWOBJECT("adodb.connection")
oRecordSet = NEWOBJECT("adodb.recordset")
loCursor = CREATEOBJECT('CURSORADAPTER')
loCommand = CREATEOBJECT('ADODB.COMMAND')
loConn.open(lcFile)
oRecordSet.cursortype = 3
oRecordSet.LockType = 2
WITH loCommand
.activeconnection = loConn
.commandtext = lcStoreProc
.commandtype = 4
*!* Parameters passing through to stored procedure
.parameters("@undel_code").value = lcGrower
.parameters("@reason").value = lcReason
ENDWITH
oRecordSet = loCommand.Execute
WITH loCursor
.ALIAS = 'updclient' && Table that will be created by the stored procedure
.DATASOURCETYPE = 'ADO'
.DATASOURCE = oRecordSet
.SELECTCMD = lcStoreProc
IF .CURSORFILL (.F., .F., 0, oRecordSet)
SELECT updclient
IF updclient.RCNT = 0
MESSAGEBOX ("Undelete unsuccessful",48,"SMS Manager")
RETURN .F.
ELSE
WAIT WINDOW "Master file data retrieval in progress" nowait
ENDIF
ELSE
AERROR(laErrors)
MESSAGEBOX(laErrors[2])
RETURN .F.
ENDIF
loCommand.ActiveConnection = loConn
ENDWITH
--------------------------END ----------------------------
--------------Store proc--------------
At end I'm passing back values:
COMMIT TRANSACTION
select @RCNT as RCNT
return
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only