Need to know easiest way to save data that has been changed in a datagridview in C# back to a local foxpro dbf file

Posted on 2012-08-21
Last Modified: 2012-08-22
Would like to know the proper method for attaching to LOCAL  tables (dbf files), and using datagrids and textboxes and editboxes etc... to edit the data then how to update this back to the local table.

Thanks a Ton!!

Question by:busycoder
    LVL 29

    Accepted Solution

    C# would need to use the foxpro odbc driver or better yet for support of VFP7+ DBFs: the Foxpro Oledb provider.

    Download it here and install it first.

    With that you can use any c# way of loading, modifying and saving data as with any other oledb data source.

    For example an OleDbDataAdapter in conjunction with an OleDbCommandBuilder will read and update data from any oledb source, also DBFs, like this:

    Follow instructions nd change the connection string to something like
    @"Provider=vfpoledb.1;Data Source=...;Collating Sequence=machine"

    Where "..." can be either a fullpath to a DBC file or a path to a directory of free DBFs.

    You need a primary key field in the dbf for the OleDBCommandBuilder to be able to create Update-SQL or Insert-SQL statements, though. In case of a free dbf a candidate key is sufficient.

    Bye, Olaf.

    Author Closing Comment

    Just what I needed to get going with this, thanks again Olaf!!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now