On 10 Nov 2005 21:46:28 -0800,
gi*******@gmail.com wrote:
Hello,
Im grabbing tables via VB code using visual foxpro ODBC drives.
The tables directory is in a mapped network drive. The code works fine
and does the job, however if the computer is idle for a while the
network drive apears to have a red X on the icon and the drive becomes
disconnected. this seems to effect the VB code from grabbing the
tables. I get an error saying the specific table cannot be found. If i
manually open the mapped network drive it than becomes reconnected and
the code can find the table again.
Is there anyway the mapped network drive can always stay connected even
if it is not in use. I want to prevent this error caused by the network
drive being disconnected.
Any suggestions?
Thanks,
Gil
I did battle with this a while back, and it's a hard one. What I finally
ended up doing is using dll calls to get the unc path the drive is mapped to,
then using the UNC path to access the tables.
I found that the API cannot be used to reliably determine whether the mapped
drive is actually connected or not, so don't be fooled into going down that
path. Since you can get the UNC path for the drive whether it's currently
connected or not, just do a little string parsing to substitute the UNC path
for the drive letter in the original path string, and you're good to go.
While we're on the subject, UNC paths are a support nightmare, no matter what
you do. People can leave drives mapped to a test copy of a database, or they
can map a drive on a system, assuming that means it's mapped for all users on
the system, while the drive mapping is actually only preserved for the user
who created the mapping. The only semi-reliable way of using mapped drives in
a multi-user environment is to user logon scripts.