I am writing a method that needs to save a DataTable in .dbf format so that it can be imported by a program on another system. Each .dbf file will be read without being modified. The file is for a is a regularly occurring, one-way data export.
I was hoping that I could just use System.IO.File.Create to create a file with a .dbf extension, instantiate an OleDbConnection to open it, and then use SQL commands to CREATE TABLE, INSERT all my DataRows into it, then simply close the OleDbConnection and the .dbf file would be usable.
If the OleDb driver can't create a properly formatted .dbf file from an empty file, since the table in each file will always have the same schema, could I create an empty template .dbf file that contained an empty copy of my table, make a copy of it with File.Copy every time I needed to make a new file, and then populate my copy?
Can it be that easy? I can't find any sample code that does more than read from .dbf files. The examples that I have seen use a couple different values/syntax for the Provider attribute in their connection string, which is confusing.
If anyone has some sample code that they could provide me with, I would appreciate it.
What is the correct provider name to use?
If I am missing a necessary step (or basic understanding), any insight would be useful.
Thanks.
David S. Alexander
Kettley Publishing
20271 SW Birch Street, 2nd Floor
Newport Beach, CA 92660-1752