Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DataSession and Queries ran from an object???/
Message
From
11/06/2014 16:27:27
Mike Yearwood
Toronto, Ontario, Canada
 
 
To
11/06/2014 11:44:42
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Web
Miscellaneous
Thread ID:
01601560
Message ID:
01601737
Views:
32
>The need here is for a single app-level Sql Server connection object that is shared by all forms, otherwise, the app will wind up with many separate hard connections to the Sql Server, which is not good.
>
>So, while I agree with the general principle of your suggestion, I believe this case calls for a solution that allows one master connection object to serve all queries, while being sure that the resulting cursors wind up in the Private DataSession of the calling form.
>
>There are indeed several ways to handle this scenario. I found a solution that I like and that fits well with existing code patterns in my app and data access framework. Which is not to say that other suggestions here are wrong or unacceptable. I was just curious to hear how others had dealt with similar matters.

It seems you're intermingling the connection handle with the data session. Can you not establish the connection handle at the app launch and have all objects in all data sessions grab the connection handle from a high level app object? Using my analogy before, you can't share my heart, but you and I can both share a connection to a higher power - FoxPro ;)

>
>
>>Hi Matt
>>
>>If form B is really contributing to the workflow of form A, have form B adopt the datasession of Form A. If Form B is truly separate from the workflow of form A, then Form B really should not be interacting with classes of Form A at all. It would be like my lending you my heart, while I'm still connected to it.
>>
>>>Here's what I'm finding...
>>>
>>>Any object in FoxPro that runs a query, whether against native DBFs or Sql Server, will create the cursor in the DataSession which was active at the time the object was created.
>>>
>>>The means that if you have a BO created in Form A with a Private DataSession, and you pass that object to Form B which has its own Private DataSession, if you use the object to run a query from Form B, the cursor will be created in the DataSession from Form A.
>>>
>>>Crazy! But true. It took be about an hour of stepping through the codez to figure this out.
>>>
>>>Does anyone know a work around, or a pattern to avoid this??
>>>
>>>
>>>.
Previous
Reply
Map
View

Click here to load this message in the networking platform