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;