Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to use CursorAdaptor with ADO record set
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
How to use CursorAdaptor with ADO record set
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP3
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
00966022
Message ID:
00966022
Vues:
49
Hi,

I am using ADO to access SQL server stored procedures. In aprevious thread I asked for help on calling these stoted procedures with parameters. Well I have worked that out now - thanks to surgey who gave me a link to a documents. I can access these procedures and send parameters to them, but how do I assign the returned record set to the CA? I want to be able to navigate through the record set and use the returned values with textboxes,grids etc.

Here is my code I use:
LOCAL loConn AS ADODB.CONNECTION, ;
      loCommand AS ADODB.COMMAND, ; 
      loException AS EXCEPTION, ;
      loCursor AS CURSORADAPTER, ;
      laErrors[1] 
      
SET MULTILOCKS ON
 
lcFile = "FILE NAME=" + "devccdb.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 = "select_bkclaman_1"
   .commandtype = 4
   .parameters("@am_code").value = ""
   .parameters("@am_desc").value = ""
ENDWITH

oRecordSet = loCommand.Execute 

? orecordset.fields("am_code").value
? orecordset.fields("am_desc").value
orecordset.movenext() 
I have descovered I can move forward with movenext but how do I move back,go to the beginning and go to end.

How can I assign the returned record set to the cursor adaptor.
When I add this code. I get and error that the connection that the "ADODB record set already open"
WITH loCursor
   .ALIAS = 'bkclaman'  
   .DATASOURCETYPE = 'ADO'
   .DATASOURCE = oRecordSet
   .SELECTCMD = 'select_bkclaman_1'
   .DATASOURCE.ACTIVECONNECTION = loConn
   loCommand.ActiveConnection = loConn
 
   IF .CURSORFILL (.F., .F., 0, loCommand)
       browse
   ELSE
      AERROR(laErrors)
      MESSAGEBOX(laErrors[2])
   ENDIF
   loCommand.ActiveConnection = loConn
  ? .cursorstatus
  WAIT WINDOW 
Thanks in advance
Stuart Reid

True nobility lies not in being superior to another man, but in being superior to one’s previous self
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform