Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataSessions 2

Status
Not open for further replies.

Neil Toulouse

Programmer
Mar 18, 2002
882
GB
Hi all!

I have hit a wall on this one for some reason!

Basically, I want to cycle through all open datasessions at a point in the app, look for a particular open table/cursor, and close it!

I did think AUSED() would be the answer but it isn't!

any advice?

Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
...basically I am looking for a collection property or similar that will tell me how many active datasessions there are at a point in time for the application (ie the number of entries in the dropdown box when you issue the SET command!)

TIA

Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
Can't help you with the property, but how about using incrementing datasessions in a TRY ... CATCH block?

Regards,
Jim
 

Neil,

How about this:

Code:
lnSessionCount = ASESSIONS(laSessions)
FOR lnI = 1 TO lnSessionCount  
  SET DATASESSION TO laSessions(lnI)
  lnTableCount = AUSED(laTables)
  FOR lnJ = 1 TO lnTableCount
    lcAlias = laTables(lnJ,1)) 
    IF lcAlias = "TheTableInQuestion"
      USE IN (lcAlias)
      EXIT
    ENDIF 
  ENDFOR 
ENDFOR

Not tested, so no guarantees offered, but it should put you on the right track.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My sites:
Visual FoxPro (www.ml-consult.demon.co.uk)
Crystal Reports (www.ml-crystal.com)
 
thanks guys, ASESSIONS() is exactly what I was after!

I like work. It fascinates me. I can sit and look at it for hours...
 
Hi Mike & others,

I had sometimes problem with SET DATASESSION command - application wasn't stable and I received strange C000005 errors later in the application run. It was in VFP6 or VFP7 and maybe such problems are no longer here. But to avoid such problems I recommend to go back to the original datasession in each method:
lnOrigSess = SET('datasession')
SET DATASESSION TO m.lnNewSession
....
SET DATASESSION TO m.lnOrigSess
 
Hi Foxdbs!

Thanks for that. Yes, I already have coded it to go back to the session form whence it came.

Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
It's a bug that only appears on my machine at the moment! We haven't really got the time to fix it properly, so the solution I have put in will do for now!

But basically, all it should be doing is checking to see if a particular table is open, if it isn't, open it, run a couple of routines and then close it again! No controls are bound to it (it's just a lookup table).

Works on the other two developer's machines but not mine. same setup etc, doing the same processes/interactions in the same order!

It's working now so I'm happy!

Neil

I like work. It fascinates me. I can sit and look at it for hours...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top