• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1163
  • Last Modified:

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

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!!

BC
0
busycoder
Asked:
busycoder
1 Solution
 
Olaf DoschkeSoftware DeveloperCommented:
C# would need to use the foxpro odbc driver or better yet for support of VFP7+ DBFs: the Foxpro Oledb provider.

Download it here http://www.microsoft.com/en-us/download/details.aspx?id=14839 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:

http://csharp.net-informations.com/dataadapter/datagridview-oledb.htm

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.
0
 
busycoderAuthor Commented:
Just what I needed to get going with this, thanks again Olaf!!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now