How to read a VFP .dbf file

2019-09-13 11:53发布

I have to read two .dbf files that came from a VFP server in SQL and manipulate them. They are sitting in a folder on the server. First, I have installed the VFPOLEDB driver, the ODBC driver, and its update. I have successfully created a linked server to the free tables, and tested it in SQL and it says the connection is fine and there's stuff there. I still can't seem to even look at the files. Anyone see anything wrong with my code? Or any tips? Sample code of known working code? I have found a lot of examples online, but when I apply with the many hours I put into modifying them, they still don't work.

Here is my code:

Select * From OPENQUERY(LINKEDSVR, 'Select * from employee.dbf') 

LINKEDSVR parameter info:

Provider: Microsoft OLE DB Provider for ODBC Drivers
Product Name: Microsoft Visual FoxPro Driver
Data source: linkedfoxpro

ODBC linkedfoxpro config:

Datasource name: linkedfoxpro
databasetype: Free Table Directory
Path: c:\somefolder

Driver: Microsoft FoxPro VFP Drver (*.dbf)

Thanks!

1条回答
疯言疯语
2楼-- · 2019-09-13 12:31

Those CDX files are not generated by SQL - that's the index file created/used by VFP. They are very prone to corruption so it is likely that the CDX was already corrupted when you got it or in transit.

By deleting the CDX file, you have removed all indexes from the table and also the source of the error.

查看更多
登录 后发表回答