relative path

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
inageib
Posts: 184
Joined: Wed 26 Aug 2009 14:11

relative path

Post by inageib » Wed 24 Nov 2010 11:36

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

mhelmstedt
Posts: 15
Joined: Thu 18 Nov 2010 11:32

Post by mhelmstedt » Wed 24 Nov 2010 12:02

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

AndreyZ

Post by AndreyZ » Wed 24 Nov 2010 12:09

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.

inageib
Posts: 184
Joined: Wed 26 Aug 2009 14:11

Post by inageib » Wed 24 Nov 2010 13:35

@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

AndreyZ

Post by AndreyZ » Wed 24 Nov 2010 14:45

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.

inageib
Posts: 184
Joined: Wed 26 Aug 2009 14:11

Post by inageib » Wed 24 Nov 2010 15:24

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 ?

AndreyZ

Post by AndreyZ » Wed 24 Nov 2010 16:03

You can continue to use this function.

inageib
Posts: 184
Joined: Wed 26 Aug 2009 14:11

Post by inageib » Wed 24 Nov 2010 20:18

ok thanks alot

Post Reply