Error connecting to dbf file at runtime

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
bryan.ray
Posts: 11
Joined: Sun 26 Jan 2014 18:07

Error connecting to dbf file at runtime

Post by bryan.ray » Thu 09 Apr 2015 22:36

Hello,
I have the procedure below to download a dbf file, then open it with uniDac.
I have a TUniConnection, TUniQuery on my form and I can successfully view the data in the TUniQuiery interface (Data editor) when I make the connection active and query active.
Here's the query: SELECT * FROM \nexattr.dbf
The Connection Database = c:\temp

everything connects and works when in design time, but when I run the program and make the connection active and query active, I get the following error.
"[Microsoft][ODBC Drdiver Manager] Data source name not found and no default driver specified"

I can't figure out why it works without a problem in design time, but not run time.

Any tips would be greatly appreciated.
Regards,
Bryan

code:

Code: Select all

var
  dbfFile : TMemoryStream;
  x : integer;
  DateStr : string;
begin
  //disconnect from the currrent dbf file.
  dbfQuery.Active := False;
  dbfConnection.Connected := False;
  //download the nexrad attributes dbf file
  dbfFile := TMemoryStream.Create;
  Try
    getNexrad.Get('https://mesonet.agron.iastate.edu/data/gis/shape/4326/us/current_nexattr.dbf',dbfFile);
    dbfFile.SaveToFile('C:\temp\nexattr.dbf');
  Finally
    dbfFile.Free;
  End;
   //now connect to the dbf file.
   if FileExists('C:\temp\nexattr.dbf') then
   begin
     dbfConnection.Connected := True;
     dbfQuery.Active := True;
     dbfQuery.First;
     while not dbfQuery.eof do
     begin
       //adjust all the date/times into the correct format
       DateStr := dbfQuery.Fields[0].Value;
       Insert('-',DateStr,5);
       Insert('-',DateStr,8);
       Insert(' ',DateStr,11);
       Insert(':',DateStr,14);
       dbfQuery.Fields[0].AsString := DateStr;
       dbfQuery.Next;
     end;
   end;
end;


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

Re: Error connecting to dbf file at runtime

Post by AlexP » Fri 10 Apr 2015 08:45

Hello,

Please specify your connection string:

ShowMessage(dbfConnection.ConnectString);

bryan.ray
Posts: 11
Joined: Sun 26 Jan 2014 18:07

Re: Error connecting to dbf file at runtime

Post by bryan.ray » Fri 10 Apr 2015 16:11

Hi Alex,
Here is the connection string when I use:
ShowMessage(dbfConnection.ConnectString);

"Provider Name=DBF;Login Prompt=False;Database=c:\temp"

It is the same at design time also when looking at the Connection String property in the Object Inspector.

Regards,
Bryan

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

Re: Error connecting to dbf file at runtime

Post by AlexP » Tue 14 Apr 2015 08:37

We couldn't reproduce the problem. Please specify the exact versions of the UniDAC, IDE, OS, and Microsoft dBase Driver.

bryan.ray
Posts: 11
Joined: Sun 26 Jan 2014 18:07

Re: Error connecting to dbf file at runtime

Post by bryan.ray » Tue 14 Apr 2015 16:09

Hi Alex,
Since the original post, I've uninstalled XE7 update 1 and installed XE8.
My mistake, I didn't check to see if UniDac was ready for XE8 first.
I'll wait until you have UniDac install package for XE8 and try again.

I'll let you know if I have the same error.
Thanks!
Bryan

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

Re: Error connecting to dbf file at runtime

Post by AlexP » Wed 15 Apr 2015 09:31

The new UniDAC version for XE8 is already available at our website for download now.

Post Reply