Discussion:
Problem working with multiple databases
(too old to reply)
Peter B.L. Rasmussen
2005-12-11 13:33:36 UTC
Permalink
I have a problem in an application that works with multiple databases
(DBCs)

It works with normally only one DBC at a time, all the DBC exist in
separate
subdirectories, and all have the same name. Occasionally I have to
distribute a change across databases, and this is where the problem shows
up.

Example:
I have one db1 which is always open, and a number of structurally
identical
db2s of which normally only one is open.
If I have 5 db2 DBCs, they could look like this:
\subdir1\db2.dbc
\subdir2\db2.dbc
\subdir3\db2.dbc
\subdir4\db2.dbc
\subdir5\db2.dbc

If I make a change in a table in the db2 in Subdir3 the change (sometimes)
must be distributed to the same table in subdirs 1, 2, 4 and 5. I have no
problem in executing this change. The problem is, that after the change
(scanning through a table in db1 that holds db2 directory names, opening
the
table in all subdirectories one by one, performing the change and closing
it
again) the db2 in subdir5 is active and a USE command will open tables in
SubDir5\db2 and not in SubDir3 as it should.

After the scan I have 6 databases open, and if I scan ADATABASES(), i see
5
copies of db2 open with corresponding pathnames to the db containers.
If I at this point execute a "SET DATABASE TO db2" I don't know which db
VFP
will select

How do I close a DBC when I am finished with it during the scan?

I know that one solution is to name all the db2s with unique names, but I
would like a solution that doesn't require this name change, as this would
cause a lot of work. I also know that the application should have been
designed otherwise to accomodate for this, but redesign is not an option
at
this point.

I have no problem with the fact that alle dbcs are open, if only I can get
it to work and select the proper dbc when I need to.

Any ideas appreciated....
"Olaf Doschke" <T2xhZi5Eb3NjaGtlQFNldG1pY3MuZGU@strconv.14
2005-12-11 19:57:15 UTC
Permalink
Hi Peter,

close database(s) closes the active database only if keyword ALL is omitted
and you can select a dbc with it's full path:

&& fill in the missing part for "...":
set database to ("...\subdir1\db2.dbc")
close database
set database to ("...\subdir2\db2.dbc")
close database
set database to ("...\subdir4\db2.dbc")
close database
set database to ("...\subdir5\db2.dbc")
close database

=> database in subdir3 remains open.

Bye, Olaf.

Loading...