Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting value from a table opened in a different DS
Message
From
09/03/2010 18:17:11
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01453599
Message ID:
01453637
Views:
78
This message has been marked as a message which has helped to the initial question of the thread.
>>>Hi everybody,
>>>
>>>In a form I call a method of the application object, that opens a cursor in a default DS. Is there a simple way of getting to this cursor's field without switching DS in code using SET DATASESSION command?
>>>
>>>Thanks in advance.
>>
>>If it is in default DS why would you switch? Or you are saying it wrong and current session is another DS? If so you need to switch the datasession or you can use the source.
>>Cetin
>
>No, In the form with private DS I call a method of the main application object, that opens cursor in Default DS. I need to access a value from that cursor in the form. The current code uses
>
>set datasession to 1
>
>...
>
>then restores the datasession using saved transform of the set('datasessionID')
>
>set datasession to &lcOldDS
>
>I think it's not a very good code and looking for alternative methods.

I think you have a misunderstanding of what default datasession means. It doesn't mean the DS in main application (maybe default DS confuses many people the same way). I don't know how would you name it in a better way but think of this:
from that form with a private DS you call a modal form with DS set to default. That 'default' is your form's private DS and not the DS that we have we launch VFP.

Anyway you meant to access to a cursor in another DS, you need to switch. While swithiching you wouldn't use &.

set datasession to thisform.datasessionID

or for others:

lnSession = set('datasession')
* ...
set datasession to m.lnSession

Alternative might be to save result in an ADO stream for example or recordset which you would be able to access from any session and get as a cursor idf you need using CA.
ADO is a simple alternative and there others like XML, array ...
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform