Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Connecting to SQL and retrieving data
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01164054
Message ID:
01164332
Views:
10
>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

I think you miss your output parameter,you have input parameters but dont have output parameter on your code....

Can you post your stored procedure?
Jojo R. dela Cuesta, B.Sc.
eConsultant, Programmer
Dalplus Technologies
http://www.dalplus.com
Previous
Reply
Map
View

Click here to load this message in the networking platform