Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Ken Murphy
  Where is Ken Murphy?
 Springhill
 Canada
 Ken Murphy
 To: Syed Imran Ulhaq
  Where is Syed Imran Ulhaq?
 Jeddah
 Saudi Arabia
 Syed Imran Ulhaq
 Tags
Subject: RE: Multiple Databases in forms
Thread ID: 155283 Message ID: 155305 # Views: 1 # Ratings: 1
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Saturday, December 29, 2007 1:33:20 PM         
   


> >
> > Imran,
> >
> > I often use multiple databases.
> >
> > IF NOT DBUSED([MyDatabase1])
> >    OPEN DATABASE [Path2\MyDatabase1.dbc]
> > ENDIF
> > IF NOT DBUSED([MyDatabase2])
> >    OPEN DATABASE [Path2\MyDatabase2.dbc]
> > ENDIF
> > 

> > The key to using more than one database is addressing the tables. For example, if you have a table in each database called "MyTable" you need to be able to tell VFP which table to work with. Use the database name as follows:
> >
> > USE MyDatabase1!MyTable IN 0 SHARED ALIAS MyTable1 && note the "!" between the database name and the table name
> > USE MyDatabase2!MyTable IN 0 SHARED ALIAS MyTable2
> > 

> > If you are dragging tables onto a D/E, then just drag the table from the correct DBC and then go into the properties tab and set the alias to what ever you want. Once you have a unique alias, that is pretty much all you need. For example:
> >
> > REPLACE MyTable1.cMyField WITH lcSomeValue IN MyTable1
> > 

> > will change the cMyField field value in the MyTable.dbf in MyDatabase1.dbc
> >
> > Ken
> > You shall know the truth - and the truth shall set you free. (John 8:33)
>
> Thanks alot sir for reply.
> When I develop application, i used dbc installed on my laptop's C drive, in actual i implement app on network (copying app and dbc on a shared folder in server).
> What I did created three folders on server (app, dbc1,dbc2) app has main application menu having two different application options billing (for dbc1) and accounts(dbc2). When i try to open form in accounts, instead of going in dbc2 folder, control asks for table placed in development environment.
> I think i highlighted my problem more clearly and you will guide me in right direction.
>
> THanks for your reply.
>
> regards,
>
> Imran

I think the problem is that your app doesn't know where to find the DBC directories. Use a SET PATH statement.

LOCAL lcPath
lcPath = [\\Server\DBC; \\Server\DBC2; \\Server\AppDir]
SET PATH TO lcPath


or you can identify the directory when you open the databases:

LOCAL lcDBC1Path, lcDBC1Name, lcDBC2Path, lcDBC2Name

lcDBC1Path = [\\Server\DBC1]
lcDbc1Name = ADDBS(lcDBC1Path)+[DBC1.DBC]
OPEN DATABASE lcDbc1Name

lcDBC2Path = [\\Server\DBC2]
lcDbc2Name = ADDBS(lcDBC2Path)+[DBC2.DBC]
OPEN DATABASE lcDbc2Name


Ken
You shall know the truth - and the truth shall set you free. (John 8:33)

ENTIRE THREAD

Multiple Databases in forms Posted by Syed Imran Ulhaq @ 12/28/2007 11:33:16 PM
RE: Multiple Databases in forms Posted by tushar @ 12/29/2007 6:15:17 AM
RE: Multiple Databases in forms Posted by Ken Murphy @ 12/29/2007 6:28:33 AM
RE: Multiple Databases in forms Posted by Syed Imran Ulhaq @ 12/29/2007 7:49:15 AM
RE: Multiple Databases in forms Posted by Ken Murphy @ 12/29/2007 1:33:20 PM