Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DBF file has two names 1

Status
Not open for further replies.

spayne

Programmer
Feb 13, 2001
157
US
I just took a new VFP job and I've run across something that is unusual to me. I can open up MyTableA and view it no problem. I need to open up MyDBC in order to open and view MyTableB. MyTableA and MyTableB have the exact same structure and contain the exact same data. I get a "file in use" error when I try to open one when the other is open. When I make changes in one, it affects the other. Is this something common in VFP table behavior and what is going on here?

TIA
 
It sounds like MyTableB is a view of MyTableA. Is that the case?

You can tell by issuing the command "MODIFY DATA MyDBC" and then right clicking on MyTableB and choosing Modify. My guess is that you'll see the view designer.

Andy

 
Actually, the table exists as a table MyTableB and a view V_MyTableB.
 
Actually, the table exists as a table MyTableB and a view V_MyTableB.

If this is the case can you "USE MyTableB" directly from the command window without opening MyDBC? It should allow you to do this and from your first post it sounds like it does not.

Andy
 
I do have to open the database first. Then I type "browse" and a form opens up where I can select from a list of tables and views. As I said before MyTableB exists in the tables section and v_MyTableB exists in the view section.
 
spayne,

If you right click on TableB in the database designer and choose Browse, does the caption of the browse window say TableB or TableA?

My thought is that maybe you are really looking at TableA and that the table name has been modified to TableB in the DBC.

Andy
 
In the status bar, when I open MyTableA, it says:
MyTableA (MyDBC:MyTableB)

When I open MyTableB it says:
MyTableB (MyDBC:MyTableB)

MyTableA exists on the hard drive. MyTableB does not. Obviously, V_MyTableB does not also.

I guess one is just a mirror of the other, but I can't figure out why someone would set it up this way.
 
but I can't figure out why someone would set it up this way
Yes, that's very confusing. There may be a method to the madness, but it's hard to tell from here.



 
Back in the day, when long file names were first coming into use, VFP had a neat way of dealing with it -- the .dbf would be 8.3 compliant, but as long as it was in a database container, you could give it a more appropriate name. so the file would be scontrol.dbf, but inside the database (let's call it MyAppDB), it would be ScreenControl. You could never reference the table as MyAppDb.scontrol, but you could as scontrol, or as MyAppDB.ScreenControl, or if the database is already open, just as ScreenControl. The view, because it is part of the DBC, uses the DBC naming convention.

In your case, MyTableA is the actual file name on the drive, MyTableB is reference name in the database and V_MyTable is a pre-defined view of the same data.
 
Thanks for the info Marsh. Is there a quick way to determine which tables on the hard drive are pointing to which reference names in the DBC?
 
A quick & dirty way to list longname vs short name of tables in .dbc -- assumes < 100 tables in dbc -- if yours is bigger, increase the array size:
Code:
close all
clear all
clear
dimension tbname(100)
? "starting..."
use DataBaseName.dbc
X=1
scan
	if upper(allt(objecttype))="TABLE" 
		TBNAME(X)=ALLT(objectname)
		X=X+1
	ENDIF
ENDSCAN
? "scanning"
Y=X-1
USE 
OPEN DATA DataBaseName SHARED
FOR X=1 TO Y
	? space(5) + tbname(x)+ "-- FileName: " + dbgetprop(tbname(x) , "Table", "Path")

NEXT
? "all done..."
 
Thanks again Marsh. I modified your code to create and write to a low level file using FCREATE() and FWRITE(). There are 108 tables in the database this way. The hard copy will be a nice way for me to sort through everything.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top