Page 1 of 1

relative path

Posted: Wed 24 Nov 2010 11:36
by inageib
Hi,
Is it possible to connect to my db using relative path ?

I have my folders like that:

/folder1/folder2/DB/
/folder1/folder2/project folder/

I tried of course to use ../DB/db.gdb but I got IO error

Thanks

Posted: Wed 24 Nov 2010 12:02
by mhelmstedt
Hi,

think it's not much efforts to create the full path to the db before connecting.

I also used that solution in the past, but it has several drawbacks:
- no design time support
- no support for the build configurations (Debug, Release, ..), unless you also copy your db to the corresponding folders
- no flexibility in case of changes in the db file name (i.e. in case of name conflicts)

So I use aliases now, just drop one line in the aliases.conf file:
mydb = full_path_to_mydb

BR,
Martin

Posted: Wed 24 Nov 2010 12:09
by AndreyZ
Hello,

You can use relative path. For example: "..\db\testdb.gdb"
In this case if your exe file is in the "D:\projects" directory, the database should be in the "D:\db" directory.

Posted: Wed 24 Nov 2010 13:35
by inageib
@AndreyZ
Thanks but I get this :
I/O error for file "..\DB\mydb.GDB"
Error while trying to open file
The system cannot find the path specified. .
@mhelmstedt
thanks

Posted: Wed 24 Nov 2010 14:45
by AndreyZ
The point is that you can use relative paths only if you are working via local protocol (when the TIBCConnection.Server property is blank). If you are using TCP/IP you should use full paths.

Posted: Wed 24 Nov 2010 15:24
by inageib
ok thanks,

one question please
I used ExpandFileName to get the parent directory as I will use absolute path but this function is very old, is there any new way to get the parent directory with Delphi ?

Posted: Wed 24 Nov 2010 16:03
by AndreyZ
You can continue to use this function.

Posted: Wed 24 Nov 2010 20:18
by inageib
ok thanks alot