Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What does CA closes alias cursor after executing?
Message
De
28/01/2005 09:15:06
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP3
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
00981617
Message ID:
00981687
Vues:
21
Hi, Stuart

You will need to make the CA not a local variable if you do not want it to disappear when the method is done. You can make the variable either part of the form, or a public variable - but you will need to remember to release it if public.

HTH
Beth

>I am using CA with ADO to access data on a SQL server database. I have a method on a form that calls links to the database and retreieves the data. I can see the alias created while the code is executing in the method. However, the minute the method terminates the cursor is gone. How can I prevent the cursor from closing once the method has terminated so that it is available through out the form like any other table or cursor.
>
>I have used the following code to create my cursor:
>LOCAL loConn AS ADODB.CONNECTION, ;
> loCommand AS ADODB.COMMAND, ;
> loException AS EXCEPTION, ;
> loCursor AS CURSORADAPTER, ;
> laErrors[1]
>
>SET MULTILOCKS ON
>
>lcFile = "FILE NAME=" + "my.udl"
>loConn = NEWOBJECT("adodb.connection")
>oRecordSet = NEWOBJECT("adodb.recordset")
>loCursor = CREATEOBJECT('CURSORADAPTER')
>loCommand = CREATEOBJECT('ADODB.COMMAND')
>
>lcStoreProc = "Get_cust_1"
>loConn.open(lcFile)
>oRecordSet.cursortype = 3
>oRecordSet.LockType = 2
>WITH loCommand
> .activeconnection = loConn
> .commandtext = lcStoreProc
> .commandtype = 4
> .parameters("@cl_cltype").value = ltCustType
> .parameters("@cl_language").value = ltLang
>ENDWITH
>
>oRecordSet = loCommand.Execute
>
>WITH loCursor
> .ALIAS = 'client'
> .DATASOURCETYPE = 'ADO'
> .DATASOURCE = oRecordSet
> .SELECTCMD = lcStoreProc
>
> IF .CURSORFILL (.F., .F., 0, oRecordSet)
> SELECT client
>
> ELSE
> AERROR(laErrors)
> MESSAGEBOX(laErrors[2])
> RETURN .F.
> ENDIF
> loCommand.ActiveConnection = loConn
>ENDWITH
>
>The cursor client is the cursor that terminates when the method is complete.
>
>Thanks in advance
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform