Author: Grigore Dolghin
Posted: 2009-04-30 at 19:32:37
Issue the following line somewhere in the beginning of your program
(before connecting to SQL Server):
SQLSetProp(0,"Shared",.T.)
This will force VFP to force first connection that will be made to be share=
d.
On Fri, May 1, 2009 at 3:02 AM, Rafael Copquin <rcopquin@ciudad.com.ar> wro=
te:
> I am rapidly updating my knowledge of VFP to start using SQL Server as a
> back end (a long overdue issue in my programmer life)
>
> I am using among other sources the book:
>
> Client-Server Applications with Visual FoxPro 6.0 and SQL Server 7.0 by
> Chuck Urwiler and others.
>
> In reference to transactions, the authors recommend to use shared
> connections.
>
> I am building a one to many form, basically an invoice header and its
> corresponding details. Both cursors can be generated using views and a
> connection can be shared with the following command:
>
> create sql view v_customers ;
> connection myconn share as..........
>
> My question is:
>
> How can I share a connection if instead of views I use cursor adapters? I
> tried this approach:
>
> start the first CA
> once the cursor is obtained, get its connection handle with cursorgetprop
> try using this handle in the datasource property of the second CA
>
> thisform.oCA.DataSource =A0 =3D
> sqlstringconnect([dsn=3Dtest;trusted_connection=3Dyes]) =A0 && for the fi=
rst CA
> nHandle =3D cursorgetprop('connecthandle', thisform.oCA.Alias)
> thisform.oCA1.DataSource =3D sqlstringconnect(nHandle) =A0 =A0 && in the =
second CA
>
> but somehow, it did not work
>
> BTW, CAs can be used in the above scenario, almost the same as with DBF's=
.
> One can issue the requery command after a tableupdate (with buffering set=
to
> 5), and they work very well. However, I can't get them to share a
> connection.
>
> TIA
>
> Rafael Copquin
>
>
>
[excessive quoting removed by server]