UniConnection error "not a valid path"

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Suits
Posts: 2
Joined: Mon 23 Aug 2021 04:42

UniConnection error "not a valid path"

Post by Suits » Mon 23 Aug 2021 05:09

I am attempting to do direct access on a dBase file using UniDac components. In working through the UniDac example from the blog posting (https://blog.devart.com/delphi-component-for-dbf.html), I receive the "is not a valid path" error when I try to connect.

I am using UniDac trial version 8.4.4 with Delphi 10.4 on a 64-bit Windows 10 system.

I have followed the example in the blog as follows:
1. I drop TUniConnection, TUniQuery, TUniDataSource, TDBFUniProvider, TDBGrid and TButton components onto the form.
2. I set the UniConnection component provider to DBF provider, dBaseIII format, and set direct access to True.
3. I enter the database path d:\mytest.dbf, which is a known and tested dbf file. (The file is not open elsewhere.)

I then get the error "d:\mytest.dbf is not a valid path."

I have tried using other dBase formats, other dBase files, and other paths, but I always get the same error.

Can you tell me what might cause this error and how to fix it?

Suits
Posts: 2
Joined: Mon 23 Aug 2021 04:42

Re: UniConnection error "not a valid path"

Post by Suits » Mon 23 Aug 2021 18:05

Follow-up: It seems the problem was I expected the path to include the database filename, but it only expects a folder. When I changed it to just the folder the database is in, it works.

Stellar
Devart Team
Posts: 496
Joined: Tue 03 Oct 2017 11:00

Re: UniConnection error "not a valid path"

Post by Stellar » Mon 06 Sep 2021 08:56

Hi,

UniDAC recognizes Database option not as path to .dbf file but as catalogue which contains database files.
Here's an example of connecting and fetching all records of "Table_Name.DBF" located in "C:\Database\DBF\":

uses
Data.DB, MemDS, DBAccess, Uni, UniProvider, ODBCUniProvider, DBFUniProvider;

procedure TForm1.Button1Click(Sender: TObject);
begin
UniConnection1.Close;
UniConnection1.ProviderName := 'DBF';
UniConnection1.Database := 'C:\Database\DBF\';
UniConnection1.SpecificOptions.Values['DBFFormat'] := 'dfAuto';
UniConnection1.SpecificOptions.Values['Direct'] := 'True';
UniConnection1.LoginPrompt := False;
UniConnection1.Connected := True;

UniQuery1.SQL.Text := ' SELECT * FROM Table_Name';
UniQuery1.Open;
end;

Feel free to contact us anytime if you get any additional question or in case you would need any kind of assistance or instructions from our side.
Best regards,
Sergey
Devart Team

Post Reply