How to read a VFP .dbf file

余生颓废 提交于 2020-01-17 03:22:33

问题


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:


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.



来源:https://stackoverflow.com/questions/7696425/how-to-read-a-vfp-dbf-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!