Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Arghhh! VFP & MTS= The nightmare never end?
Message
De
02/04/2002 09:50:32
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00639670
Message ID:
00639921
Vues:
26
This works in VFP6 just fine, it's not a VFP bug at all. Try changing your connection to client side cursor (loCon.CursorLocation=adUseClient) before opening and updating your rs. FWIW, this three procs work for me from a VCX compiled into a multithreaded DLL:
*-- in method adoconnect:
This.oCn = CreateObject("ADODB.Connection")
With This.oCn
	.CursorLocation = adUseClient
	.ConnectionString = "my_connection_string"
	.Open
EndWith

*-- in GetBlank() method
oRS = CreateObject("ADODB.Recordset")
With oRS
	.LockType = adLockBatchOptimistic
	.ActiveConnection = myConn &&(from adoconnect())
	.Open("Select * From " + cTable + " Where 1=0")
	.ActiveConnection = .Null.
EndWith
Return oRS

*-- in UpdateBatch() method
LParameters tRst
With tRst
	.ActiveConnection = myConn
	.UpdateBatch
	.ActiveConnection = .Null.
EndWith
Some code has been removed to show the bare bone parts. When updating the RS from the client side it is always good to only return the updated rows and not the whole returned RS. Look at the Filter and MarshalOptions properties of the RS. In my example I just bring an empty RS. Hope this helps.

PS Now, you didn't have to spend $2200 to get VFP7, you can get an upgrade for around 15% of that or MSDN Professional for about 25% of that.

>Hi,
>
>I try to do this very simple task:
>
>1- Get a disconnected ADO 2.6 recordset with data of a Sql Server database from a VFP COM server.
>2- Update in the client
>3- Send the recordset to the COM VFP server, update it and refresh the changes..
>
>I have this dummy test:
>
>1- PRG with the call:
>LOCAL loSrv,loAdo as ADODB.Recordset
>
>*-- Basura.Basura is the COM server
>
>*-- Uncomment to use the VFP class
>*loSrv=NEWOBJECT('basura','d:\basura\basura.vcx')
>loSrv=CREATEOBJECT('basura.basura')
>CLEAR
>loAdo=loSrv.Obtener()
>
>IF VARTYPE(loAdo)='O' AND !ISNULL(loAdo)
> ?'Registros'+STR(loAdo.RecordCount)
> ?'Source '+loAdo.Source
>
> loAdo.AddNew()
> loAdo.Fields('Cod').Value='01'
> loAdo.Update
>
> loSrv.Actualizar(loAdo)
>ENDIF
>
>
>2- The code IN the vfp server
>
>DEFINE CLASS basura AS custom OLEPUBLIC
>
>
> Name = "basura"
>
>
> PROCEDURE actualizar
> LPARAMETERS loAdo as ADODB.Recordset
>
>
> LOCAL lcCon as String,lcSql as String,loCon as ADODB.Connection
>
> lcCon="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Basura"
>
>
> loCon=CREATEOBJECT('adodb.Connection')
>
> loCon.Open(lcCon)
>
> *loAdo=CREATEOBJECT('adodb.recordset')
>
> loAdo.ActiveConnection=loCon
>
> loAdo.UpdateBatch()
>
> loAdo.ActiveConnection=NULL
> ENDPROC
>
>
> PROCEDURE obtener
> LOCAL loAdo as ADODB.Recordset,;
> lcCon as String,;
> lcSql as String,;
> loCon as ADODB.Connection
>
> loCon=CREATEOBJECT('adodb.Connection')
> lcCon="Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Basura"
> lcSql="SELECT * FROM Prueba"
>
> loCon.Open(lcCon)
>
> loAdo=CREATEOBJECT('adodb.recordset')
>
> loAdo.CursorLocation= 3 && adUseClient
> loAdo.LockType= 4 && adLockBatchOptimistic
> loAdo.CursorType= 3 && adOpenStatic
> loAdo.ActiveConnection=loCon
>
> loAdo.Open(lcSql)
>
> loAdo.ActiveConnection=.NULL.
>
> RETURN loAdo
> ENDPROC
>
>
>ENDDEFINE
>
>If you want reproduce the code, create a Sql Database called "basura2 and 1 table called "Prueba" with the column "Cod" char(3)
>
>Incredible, when you out the server inside MTS/COM+ and you run the test, the source is returned blank!!!! That is NOT good because this meaning thta subsecuent calls fail, beecause the source is empty and is impossible call Resync, Requery, etc...!!!
>
>I buy VFP 7 *dreaming* that this problem is gone...
>
>I spend 3 monts in a lot of problem with VFP (and 2 with Win98). In this moment i like to return to the past, send VFP to the trash, say to my boss try best with delphi and get the job done in half or less of the time (i spend 1 year in this project...) But now this is not a option. I need a solution fast.... Or i lost $2200 dollars for this things...
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform