Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need to rename a database
Message
From
07/02/2002 05:58:33
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
06/02/2002 13:55:58
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00616146
Message ID:
00616476
Views:
21
>Hi Cetin,
>
>>>
>>>1. Can I have two databases with the same name open at the same time reliably. They reside in two different directories. (I assume no but...)
>>>
>>
>>1) You can.
>>Cetin
>
>How? Reliably? Assuming identical tables in each? What can you do once they are open?

Yes reliably. All tables also have backlink info in their header pointing to their own DBC.

lcPath1 = 'c:\MyPath\DataPath1\'
lcPath2 = 'c:\MyOtherPath\DataPath2\'
lcTable = 'SameTableNAme'
lcView = 'SameView'
lcDBCName = 'SameDBC'
use (lcPath1+lcTable) alias 'First' in 0
use (lcPath2+lcTable) alias 'Second' in 0

I don't use DBCName!tableName syntax often. But it doesn't matter either.
lcPath1 = 'c:\MyPath1\data\'
lcPath2 = 'c:\MyPath2\data\'
lcTable= 'MyTable'
lcView = 'MyView'
lcDatabase='MyDBC'
open data (lcPath1+lcDatabase)
use (lcPath1+lcDatabase+'!'+lcTable) alias t1 in 0
use (lcPath1+lcDatabase+'!'+lcView) alias v1 in 0
open data (lcPath2+lcDatabase)
use (lcPath2+lcDatabase+'!'+lcTable) alias t2 in 0
use (lcPath2+lcDatabase+'!'+lcView) alias v2 in 0

lnInUse=aused(arrCursors)
For ix=1 to lnInUse
  lnType = cursorgetprop('SourceType',arrCursors[ix,1])
  ?
  ? 'Info for alias '+arrCursors[ix,1]
  ? '---------------------------------------'
  ? 'DBC       :'+cursorgetprop('Database',arrCursors[ix,1])
  ? 'DBF       :'+dbf(arrCursors[ix,1])
  ? 'DBObject  :'+cursorgetprop('SourceName',arrCursors[ix,1])
  ? 'DBType    :'+iif(lnType=3,'Table',iif(lnType=2,'RemoteView','LocalView'))
  Set database to (cursorgetprop('Database',arrCursors[ix,1]))
  If cursorgetprop('SourceType',arrCursors[ix,1])=3
    ? 'TablePath :'+dbgetprop(cursorgetprop('SourceName',arrCursors[ix,1]),'TABLE','Path')
  Else
    ? 'SQL       :'+dbgetprop(cursorgetprop('SourceName',arrCursors[ix,1]),'VIEW','SQL')
  Endif
Endfor
A problem might arise if views used simply DBCName!tablename instead of pathing the DBC but I think anyone using same names should be prepared for it.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform