Page 1 of 1

UniDAC MS Acces connection

Posted: Thu 02 Oct 2014 18:37
by Tango
Can I make relative path specified? If I make absolute path specified and later the database where otherwise move I get error message

Here a Screenshot

Image

Thanks

Re: UniDAC MS Acces connection

Posted: Fri 03 Oct 2014 06:46
by AlexP
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';

Re: UniDAC MS Acces connection

Posted: Wed 15 Oct 2014 10:04
by Tango
Thanks,

I've tried it. When I enter it in the source code I get
UniConection1 conected to false or UniQuery1 active to false

I give this one also in the source text, I get errors

UniConnection1.Database: = ExtractFilePath (Application.ExeName) + 'Abrechnung.accdb';
UniConnection1.Connected: = 'true'
UniQuery1.Active: = 'true'

I get error

Re: UniDAC MS Acces connection

Posted: Wed 15 Oct 2014 11:26
by AlexP
Please provide the text or a screenshot of the error message occurring on connection.

Re: UniDAC MS Acces connection

Posted: Thu 16 Oct 2014 05:59
by Tango
here screenshot
Image

Re: UniDAC MS Acces connection

Posted: Thu 16 Oct 2014 07:14
by AlexP
You are trying to assign a string value to a Boolean property. More details about this error are available in the documentation

Re: UniDAC MS Acces connection

Posted: Thu 16 Oct 2014 13:08
by Tango
how should it be the right?
If I example source would have at least as could have been combined with relative path, I could learn a lot

Re: UniDAC MS Acces connection

Posted: Fri 17 Oct 2014 08:18
by bork
Code:

Code: Select all

UniConnection1.Connected := 'true';
it is the same as:

Code: Select all

var
  b: boolean;
begin
  b := 'true';
end;
This code can't be compiled, because a string constant can't be assigned to a boolean variable or property.

To get more information about data types compatibility and errors, please read the documentation.

Re: UniDAC MS Acces connection

Posted: Sun 19 Oct 2014 16:41
by Tango
I do not understand :(
have b defined as boolean
and UniConnection1.Connected: = b written does not work
ye have no Example where the database connection works with source code?

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var
b: boolean;
begin
b:='true';
UniConnection1.Database:= ExtractFilePath (Application.ExeName) + 'Abrechnung.accdb';
UniConnection1.Connected:= b
UniQuery1.Active:= b
end;

Re: UniDAC MS Acces connection

Posted: Mon 20 Oct 2014 11:05
by bork
The code:

Code: Select all

b := 'true';
can't be compiled, because b has the boolean data type, and the 'true' constant has the string data type. The string data type can't be assigned to a boolean variable or property.

You can assign only boolean constant to boolean variable or property :

Code: Select all

b := true;
or you should convert the string constant to boolean:

Code: Select all

b := StrToBool('true');
Please read the documentation for Delphi data types compatibility again: here