How to read/write dBase III files using C#/.NET ODBC or OLE?

后端 未结 5 806
鱼传尺愫
鱼传尺愫 2020-12-16 04:03

I have searched for various techniques on how to read/write dBase III (dbf) files using OLEDB or ODBC with C#/.NET. I have tried almost all of the tecniques posted, but wit

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-16 04:50

    I have offered many answers on working with database files (more specifically VFP, but the Microsoft VFP OleDb provider will recognize older dbase files. You can do a search to find more of these links via:

    user:74195[vfp][oledb]

    First, I would start with getting the Microsoft VFP OleDb Provider download.

    Next, if you already have some dbf files you are trying to connect to for testing, you need to establish a connection. The connection must point to the PATH where the files are located, not the specific .dbf file. So, if you have a folder with 20 tables in it, once you connect to the PATH, you can query from any/all the tables via standard VFP-SQL Syntax (common with many sql the overall structure, but different based on some functions like string, date and number manipulations).

    Learn about PARAMETERIZING your queries. With VFP OleDb, parameters are done with the "?" character as a place-holder, so the parameters need to be added in the exact same sequence as they appear in the query. The "?" can appear as field values, join conditions, where criteria, etc.

    The following are a FEW to get you started to HOPEFULLY get you started with a valid connection, query, then insert/update/delete with parameters.

    1. Sample showing a connection string and simple query from a table

    2. Shows a parameterized sql-insertbut in this case gets the data from another data source, such as sql-server and creating a VFP/dbf style table from it. It goes through cycling through records and pulling values for each parameter and inserting.

    3. and another showing parameterized SQL-update

    Good luck, and there are plenty of others who answer on VFP and OleDb Access, these are just some that I have specifically participated in and show functional implementations that may have something you may otherwise may have missed.

提交回复
热议问题