Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Connecting to SQL and retrieving data
Message
From
24/10/2006 10:06:05
 
 
To
24/10/2006 07:07:49
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:
01164084
Views:
15
How are you deleting the record to begin with? In SQL Server, when you delete a record, it is gone, unlike VFP where it is simply marked for deletion.

>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
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Reply
Map
View

Click here to load this message in the networking platform