Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Find in which DS the particular table is open - Urgent h
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00430461
Message ID:
00430575
Views:
26
Alex,

That's great. I've just written the following function based on your and Mike idea. Thanks a lot.
********************************************************************
*  Description.......: GetTableDS - returns owner DS ID for passed alias
*  Calling Samples...: ?GetTableDS('TranMstr')
*  Parameter List....: pcAlias
*  Created by........: Alex Wieder  #031264
*  Modified by.......: Nadya Nosonovsky 10/17/2000 04:34:25 PM
********************************************************************
lparameter pcAlias && Alias for which we want to find owner DS
** Parameter check
if empty(pcAlias) or vartype(pcAlias)<>'C'
     return 0
endif
pcAlias=upper(pcAlias)

local lnMaxDS, llValidSession, li, lnTableCount, lnRetDS, lcOldError, lcOldExact
lnRetDS=0
lnMaxDS = 20 && Max No. of sessions I want to go through
local array laAlias[1]
lcOldError=on('error')
lcOldExact=set('exact')
on error llValidSession = .f. && Supress Error mesages
set exact on && To perform full string comparision
for li = 1 to lnMaxDS
     llValidSession = .t.
     lnTableCount = aused(laAlias,li) && If DS doesn't exist, this line throw an 1540 error
     if llValidSession and lnTableCount>0
          if ascan(laAlias,pcAlias)>0 && This alias is found in this DS
               lnRetDS=li
               exit
          endif
     endif
next
on error &lcOldError
if lcOldExact='OFF'
     set exact off
endif
return lnRetDS
>Hi Nadya,
>
>Try this as a starting point. I was trying to do something simmilar not long ago and this is where I started - note, this code is untested, so I don't know if it works:
dime aAlias(1)
>
>* Max No. of sessions I want to go throughlnDataSession = 20
>ON ERROR llValidSession = .F.
>for lndatasession = 1 to lnsessioncount
>   llValidSession = .t.
>   set datasession to (lnDataSession)
>   if llValidSession
>      lnTableCount = aused( aAlias)
>      for lnTable = 1 to lnTableCount
>         select (lnTable)
>         if !empty( alias())
>            ? alias()
>         endif
>      next
>   endif
>next
Alex
>
>>Hi everybody,
>>
>>Is there a way to find out in which DS (number) the particular table (alias) is opened? May be VFP function?
>>
>>Thanks a lot in advance
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform