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: 155291 # Views: 1 # Ratings: 0
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Saturday, December 29, 2007 6:28:33 AM         
   


> Dear Members
> hi
>
> I have designed 2 different applications. Both have different screens and databases.
> Now I am trying to merge them into one form and trying to run applications thru menus.
> Can I use application in one directory and databases in two sub-folders.
> At design time, i have placed table in DE and placed same dbc on network for online version of application.
> I tried to use set database to but form searches table in Design time dbc.
> how i can use two different databases in single application.
> thanks for help.
> regards,
>
> Imran Syed

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)

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