C# Read from .DBF files into a datatable

后端 未结 2 857
孤城傲影
孤城傲影 2020-12-15 12:36

I need to connect to a .dbf file in visual Studio using C# and populate a data table. Any ideas? I can currently view the tables in Visual Fox Pro 9.0

C

2条回答
  •  佛祖请我去吃肉
    2020-12-15 13:07

    Visual FoxPro DBFs are NOT dBase IV DBFs, and as such are unreadable by most versions of Microsoft Access's Jet database engine. (MSDN has some specifics, if you care.)

    You'll need to either export the DBF from FoxPro into an actual dBase format, or you'll need to have C# open it using the Visual FoxPro OLEDB provider.

    Once you have the provider installed, you'll need to change the "Provider" argument of your connection string to the following, assuming your DBF is in that folder.

    Provider=VFPOLEDB.1;Data Source=C:\Users\PC1\Documents\Visual FoxPro Projects\;
    

    (Use an @"" string format; you missed a slash in the code sample, between PC1 and Documents.)

提交回复
热议问题