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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP Foxpro Dos 2.6a - SQL CREATE TABLE

Status
Not open for further replies.

Foxtech

Programmer
May 26, 2001
66
0
0
CA
Hi everyone,

I use SQL-Create table but if I don't specify the path so the file will be created in the current location by default.

My application runs under XP/Pro network with LinkSys router 5 hubs. The database is located in E: drive on Server
and the client 1 was mapped with server but is assigned the letter H: is equal to E: on server

If I hard code E: drive in my program so I am going to have a problem if the CLIENT is mapped and assigned H:

Do you know any existing functions that allow me to get the path where is my the database located?
examples: sys(????) or getpath()

I don't want to put Default=E:\data in config.fp because all files will be created in E:\data by default.

thanks in advance

Foxtech


 
If you're in Fox 2.6 then you don't have a database as such, just a collection of tables in dbf files. So you can't ask where the database is because there isn't one.

There are two functions that answer two other questions but which mihgt be useful:

DBF(aliasname) gives the full name and path of the table behind this alias. You could open any of your tables and extract the path.

SYS(16,1) gives the name and path of the master program.

Memory fails me but ISTR that JustPath() was still part of FoxTools in Fox 2.6 rather than being a function in its own right.

Geoff Franklin
 
You don't have to put Default= whatever in config.fp because you can enter set default to whatever before you issue the sql create table command.
store the present location to a variable before you set default to whatever by issuing:

previous = curdir()

after the create table command issue:

set default to (previous)

Rob.
 
hi guys,

Finally, it's worked.

Here are the codes:

Public mDrive

mDrive = substr(sys(16,1),1,3)

set default to &mDrive

Create table file...

set default to


thanks a lot ... you are the experts
FoxTech
 
and using:

set default to (mDrive)

is even faster and uses less memory.

Rob.

 
DBF() requires
SET FULLPATH ON
to get the full path. Unfortunatley to use that, you must have already opened the database. If the DBF is in the same place as the program, you can use PROGRAM() to get the drive letter that the currently running PRG is on. Otherwise, you can do something like this.

do case
case file("E:\MYPROJ\MYTABLE.DBF")
m.masterpath="E:\MYPROJ\"
case file("H:\MYPROJ\MYTABLE.DBF")
m.masterpath="H:\MYPROJ\"
endcase
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top