Relative Path to Access mdb

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
FriedhelmDrecktrah
Posts: 2
Joined: Sun 06 Jan 2013 20:41

Relative Path to Access mdb

Post by FriedhelmDrecktrah » Sun 06 Jan 2013 21:00

Hi,
how can I set a relative Path in UniConnection.Database for an Access mdb Database file?
E.g. UniConnection.Database:= 'data\MyDb.mdb' does not work.
It only works if I set an absolute path on my development machine, but this path
does not exist on the client computer :-(

Thanks and greetings
Friedhelm Drecktrah

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Relative Path to Access mdb

Post by AlexP » Tue 08 Jan 2013 14:20

Hello,

MS Access ODBC driver doesn't support relative paths, therefore you should generate a full path. For example, if the DB file is located in a ..\data\ folder relatively to your application, you can use the following code to generate the path:

UniConnection1.Database := ExtractFilePath(Application.ExeName) + 'data\MyDb.mdb';

FriedhelmDrecktrah
Posts: 2
Joined: Sun 06 Jan 2013 20:41

Re: Relative Path to Access mdb

Post by FriedhelmDrecktrah » Tue 08 Jan 2013 16:10

Hi,
good idea, thank you!

Greetings
Friedhelm

Post Reply